News Feed
Jobs Feed
Sections




News Archive
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

PHP Magazin: PHP4 has to die (No more PHP4-based Articles)

Arnold Daniels' Blog: Wrong PHP prediction: you don’t need to patch PHP to run multiple versions

Robert Basic's Blog: Starting with Zend Framework - part 2

Jakub Zalas' Blog: Mocking Symfony Container services in Behat scenarios with Mockery

TotalPHP.com: How to Read an RSS Feed with PHP 5


Community Events











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


framework example opinion unittest conference series zendframework2 release phpunit functional development introduction community podcast language code tool interview testing application

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