dhope Posted February 19, 2012 Share Posted February 19, 2012 Hi, I have just started creating my first class in php. I'm trying to assign $_SERVER['REMOTE_ADDR']; to a protected variable but I keep getting an error message. I'm still trying to get my head around oop php. My current code is "protected $user_ip = $_SERVER['REMOTE_ADDR'];" and the error message is "Parse error: syntax error, unexpected T_VARIABLE". Link to comment https://forums.phpfreaks.com/topic/257300-assigning-_serverremote_addr-to-variable/ Share on other sites More sharing options...
trq Posted February 19, 2012 Share Posted February 19, 2012 What you are attempting is a bad idea in the first place. You should be passing $_SERVER['REMOTE_ADDR'] into your objects __construct instead. Link to comment https://forums.phpfreaks.com/topic/257300-assigning-_serverremote_addr-to-variable/#findComment-1318883 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.