Blog for web designers

if condition to detect localhost and server

if condition to detect localhost and server

Copy the below php code of if condition to detect localhost and server.

 <?php 
if($_SERVER['HTTP_HOST'] =='localhost:8080') {
define('DB_NAME', 'localdatabasename');
define('DB_USER', 'root');//mostly root
define('DB_PASSWORD', '');
} else {
define('DB_NAME', 'server database name');
define('DB_USER', 'server database user');
define('DB_PASSWORD', 'dbpassword');

}
?>

Santosh Shah

My name is Santosh Shah and blogs at santosh-shah.com

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.