This question already has an answer here:
- Using namespace in if / else statements 4 answers
I'm trying to use the browscap-php
in a if else statement in Apache
& PHP 5+
. I'm using the Browscap.php file like this below as a example.
Working example:
<?php
require 'Browscap.php';
use phpbrowscap\Browscap;
if ($newdata == "1") {
$current_browser = $bc->getBrowser();
} else {
}
?>
Not working example:
<?php
if ($newdata == "1") {
require 'Browscap.php';
use phpbrowscap\Browscap;
$current_browser = $bc->getBrowser();
} else {
// do not load anything dealing with browscap
}
?>
The working example works fine but the second I place the use
function in the if else statement it doesn't work. I don't want browscap
loaded when I don't need to check for that information. How would I go about doing this?
</div>