This is what I use:
if ('localhost' == $_SERVER['HTTP_HOST']) {
// [] you are local
} else {
// [] you are live
}
Question
Working on a project where i am using wamp and phpmyadmin to make a website. I am doing a little bit of databasing. I would like to have a file that would could work on both my local database as well as my live database. exp.
Local machine:
$server = 'localhost';
$database = 'exp_database';
mysqli_connect($server,'root','',$database);
Live:
$server = 'localhost';
$db_username = 'username';
$db_password = 'dbpass';
$database = 'exp_database';
$con=mysqli_connect($server,$db_username,$db_password,$database);
I have been looking for a tutorial or something that fits my situation. I might be going about this all wrong, but please direct me in the right direction.
Solution
This is what I use:
if ('localhost' == $_SERVER['HTTP_HOST']) {
// [] you are local
} else {
// [] you are live
}