Sorry for beginning "What the HECK!?" but this is driving me absolutely insane.
OK, this one is driving me INSANE. I SWEAR there are other files on this very server written in ways this is constantly failing.
First of all, I am using PHP Version 5.2.6-3
Here is some code that works:
Code: Select all
class ipstuff{
var $userIP = '123';
}
$teststuff = new ipstuff;
echo $teststuff->userIP;Code: Select all
class ipstuff{
$userIP = '123';
}
$teststuff = new ipstuff;
echo $teststuff->userIP;Parse error: syntax error, unexpected T_VARIABLE, expecting T_FUNCTION in /home/daniel/public_html/testing/se/se/index.php on line 8
and this does not work either:
Code: Select all
class ipstuff{
var $userIP = $_SERVER['remote_addr'];
}
$teststuff = new ipstuff;
echo $teststuff->userIP;Parse error: syntax error, unexpected T_VARIABLE in /home/daniel/public_html/testing/se/se/index.php on line 8
Nor does this work:
Code: Select all
class ipstuff{
var $userIP = '123';
}
echo ipstuff::$userIP;Code: Select all
class ipstuff{
static var $userIP = '123';
}
echo ipstuff::$userIP;Parse error: syntax error, unexpected T_VAR, expecting T_VARIABLE in /home/daniel/public_html/testing/se/se/index.php on line 8
which is OK, I guess, it needs a variable, not a var, so I'll try:
Code: Select all
class ipstuff{
static $userIP = '123';
}
echo ipstuff::$userIP;Code: Select all
class ipstuff{
static $userIP = $_SERVER['REMOTE_ADDR'];
}
echo ipstuff::$userIP;Parse error: syntax error, unexpected T_VARIABLE in /home/daniel/public_html/testing/se/se/index.php on line 8
yet if I take it out and just run:
Code: Select all
echo $_SERVER['REMOTE_ADDR'];Can SOMEONE PLEASE explain this insanity!!!! Why do I suddenly have to declare my variables in my classes, instead of just using them? Why will $_SERVER break a class that works fine for everything else? Why can't I use a "static var" and why does it do similar things if I try to even declare a "private" var!?