News Feed
Sections




News Archive
Looking for more information on how to do PHP the right way? Check out PHP: The Right Way

ThinkPHP Blog:
Spooky Action at not so much Distance
September 20, 2007 @ 10:27:00

Martin Brotzeller came across an interesting behavior in a script he was recently working on involving two classes and an error that should have been thrown.

Over the weekend i encountered a twist in PHP that really left me wondering. I made a mistake and i thought i should have gotten an error, or at least a warning. I got a completely unexpected behavior instead. According to our PHP Oracle this is just a legacy from PHP 4 though and there was much Discussion whether changing this behavior would break old apps. I think it's a possible source of hard-to-track errors though.

His code creates an object, a and calls the bar() method. Inside bar(), object b is created and the foo() method of b is called. The real oddity comes in when, inside the b->foo() call, $this->mprint() is called but it's the one defined in object a that executes, not in b.

0 comments voice your opinion now!
class spooky action php4 object class method class spooky action php4 object class method


blog comments powered by Disqus

Similar Posts

Tony Bibbs' Blog: Geeklog_Generator 1.0.0 Released

Michael Nitschinger's Blog: Quick Tip: Lithium Redirect

DevShed: Using Visitor Objects with MySQL Data Sets in PHP 5

Zend Developer Zone: Wrapping C++ Classes in a PHP Extension

Patrick Allaert's Blog: Coding standards: converts PHP4 style constructors to PHP5 one


Community Events





Don't see your event here?
Let us know!


tips package list interview release opinion language symfony voicesoftheelephpant api install introduction bugfix laravel library community series podcast deployment framework

All content copyright, 2014 PHPDeveloper.org :: info@phpdeveloper.org - Powered by the Solar PHP Framework