Marten Lehmann wrote:
Hello,
I'm using some php-classes which worked fine with php-5.0.4. Now I tried
to upgrade to php-5.2.6, but the classes give a lot of errors. If I set
error_reporting(E_ALL);
I see messages like
Notice: Undefined property: FastTemplate::$main in
/whereever/inc.template.php on line 293
Notice: Undefined property: current_session::$cust_id in
/whereever/inc.init.php on line 117
In inc.template.php there are a lot of calls like $this->$key. In
inc.init.php there are calls like $session->cust_id.
to fix these errors, you would need to modify the code so it does something
like this.
where it calls $this->$key you need to check and make sure that $key exists
before you trying call for it.
So something like this would work.
if ( isset( $this->$key ) ) {
$this->$key;
} else {
$this->$key = null;
}
You didn't show any context in which you are using the above code. So I don't
know what will actually work in your situation. Show a little more code that
includes the method in which $this->$key is called.
You will want to look at using the Overloading feature of PHP5. Check out
this page for overloading examples
http://us2.php.net/manual/en/language.oop5.overloading.php
Take note of the __get() and __set() methods. The __get method checks to see
if the key exists before it tries working with it.
What has changed in php-5.2.x so that these calls don't work any more?
What is the new, required form to use objects in a similar manner
(unfortunately I have no ressources to code these classes from scratch)?
Thanks.
Kind regards
Marten
--
Jim Lucas
"Some men are born to greatness, some achieve greatness,
and some have greatness thrust upon them."
Twelfth Night, Act II, Scene V
by William Shakespeare
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php