Is it possible to use some sort of check before adding namespaces to a script that might be run on a php 5.2 server?
For example, if you want to use doctrine(which requires 5.3) on a 5.3 server, and fallback to PDO on a 5.2 server.
Example:
if($pdo){
//RETURN a pdo connection
}
else if($doctrine){
//this will fail even if doctrine is false because namespaces are being used
$classLoader = new Doctrine\Common\ClassLoader('Doctrine\Common');
$classLoader->register();
}
This is just an example, I am sure I can get this to work without namespaces, but just wondering if there is anyway to use them within an IF statement.
You could tuck the Doctrine code into a separate PHP file and require() it inside the else if branch.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With