[code=php] protected function checkLocation() //check if we’re on my computer or the server
{
if (str_replace(‘xampp’, ”, $_SERVER[‘SCRIPT_FILENAME’]) != $_SERVER[‘SCRIPT_FILENAME’])
{
return ‘host111.hostmonster.com’;
}
else
{
return ‘localhost’;
}
}
private $db_host = $this->checkLocation(); // Database Host
private $db_user = ‘myusername’; // Username
private $db_pass = ‘mypass’; // Password
private $db_name = ‘mydbname’; // Database
I’m getting this error: [I]PHP Parse error: syntax error, unexpected T_VARIABLE in /home2/myuniverse/public_html/site/alpha/Dogs.class.php on line 27
Line 27 is:
[code=php]private $db_host = $this->checkLocation(); // Database Host
For testing purposes, I did the following to the checkLocation() function, and it did not help:
[code=php]protected function checkLocation()
{
return ‘localhost’;
}
For testing purposes I also did the following, and the parse error DID go away:
[code=php]private $db_host = ‘localhost’; // Database Host
So, what I want to know is, how can I get the parse error to go away, but still get to use my checkLocation() function to determine the path to the database?