Hello,
I was wondering if it is possible for some PHP code to tell if it is running from a online web server or from a local host server.
I ask this because commenting out code that will run on a localhost but not an online web server.
For example with MYSQL, my login credentials are completely different from the online MYSQL credentials.
I am using Filezilla for my FTP, Xampp for my localhost and www.000webhost.com from a free online web server. It would be nice just to FTP a working localhost php file to the web server without modifying the code.
Here is what I am thinking.
I use some If, ElseIF statements to achieve this
<?php
if ($localhost == TRUE) {
mysql_connect("localhost", "test", "") or die(mysql_error());
echo "Connected to Localhost<br />";
}
elseif (($localhost == FALSE) {
mysql_connect("mysql3.000webhost.com", "username", "password") or die(mysql_error());
echo "Connected to online server<br />";
}
?>
I don't know if this is the right way of doing this. Can someone please help? thanks.