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". Quote 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. Quote 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
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.