Jump to content

$_SERVER details in a class


Jagand

Recommended Posts

Hi,

 

I am writing a little code that would populate the server name based on $_SERVER['HTTP_HOST']. My code and the error I encounter are given below. Can we ever use $_SERVER in a class?

 

 

class Get_server_name {

 

if ($_SERVER['HTTP_HOST'] == 'localhost'):

$hostname = 'localhost';

else:

$hostname = 'my remote server';

endif;

 

}

 

Error I get: Parse error: parse error, expecting `T_FUNCTION' in

 

Link to comment
https://forums.phpfreaks.com/topic/214370-_server-details-in-a-class/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.