I have a class like
class blah extends blahblah{
  private $variable = '5';
  function somefunction(){
    echo $variable;
  }
}
this works in php 5, but not in php 4. I get a error:
Parse error: parse error, unexpected
T_VARIABLE, expecting T_OLD_FUNCTION
or T_FUNCTION or T_VA....
I also tried with public and static. Same error.
How can I add a variable inside that class that I can access from al开发者_StackOverflow中文版l class functions?
private is not a valid keyword in PHP 4 change it to var $variable = '5';
also the function is wrong it should be...
class blah extends blahblah{
  var $variable = '5';
  function somefunction(){
    echo $this->variable;
  }
}
In PHP4, member variables are declared with var:
var $variable = '5';
But you still have to access it via $this->variable in your function (I think, I'm not so familiar with PHP4).
That said, if possible, upgrade! PHP4 and "OOP" is more pain than fun.
Update: Ha, found it, some documentation about Classes and Objects in PHP4.
 
         
                                         
                                         
                                         
                                        ![Interactive visualization of a graph in python [closed]](https://www.devze.com/res/2023/04-10/09/92d32fe8c0d22fb96bd6f6e8b7d1f457.gif) 
                                         
                                         
                                         
                                         加载中,请稍侯......
 加载中,请稍侯......
      
精彩评论