Replace
if ($detect->isMobile()) {$mobile = '1';}
With
if ($detect->isMobile()) {$mobile = '1';}
See if that works
Pregunta
I am using Mobile detect and i want to remove my custom.css when a mobile or tablet is browsing the site.
Can enyone explain what i am doing wrong ?
<?php
// Include and instantiate the class.
require_once 'php/mobile_detect.php';
$detect = new Mobile_Detect();
if ($detect->isMobile()) {$mobile = '1';}
if ($mobile == 1) {
echo '<link href="'.$site.'css/mobile.css'" rel="stylesheet">';
}else {
echo '<link href="'.$site.'css/desktop.css'" rel="stylesheet">';
}
?>
Solución 2
Replace
if ($detect->isMobile()) {$mobile = '1';}
With
if ($detect->isMobile()) {$mobile = '1';}
See if that works
Otros consejos
You have a problem with mismatched quotes as well as with your ->
. Try
if ($detect->isMobile()) {$mobile = '1';}
instead
With your mismatched quotes, use
echo '<link href="'+$site+'css/mobile.css" rel="stylesheet">';
This is what i did and it works.
// Include and instantiate the class.
require_once 'php/mobile_detect.php';
$detect = new Mobile_Detect();
if ($detect->isMobile()) {$mobile = '1';}
if ($mobile == 1) {
echo '<link href="css/mobile.css" rel="stylesheet">';
}else {
echo '<link href="css/custom.css" rel="stylesheet">';
}
?>