Who would have thought?
When I adapted the code for the TYPO3 Extension T3Blog (on which this Blog is based) a bit for my own purposes, I was led to a very strange behavior in PHP.
In the existing code, I had calls to a static method in a static class. To be able to XCLASS the class, I made an instance of this class – and suddenly nothing worked anymore.
After a bit of digging around in the code I found the following construction:
class A_Real_Object
{
var someVar = "bla";
function callSomething()
{
StaticClass::doSomething();
}
}
class StaticClass
{
function doSomething()
{
echo $this->someVar;
}
}
And the function doSomthing really would output “bla”!
Every self-respecting programming language would here cry like there is no tomorrow, but PHP just accepts the code – and does something totally unexpected.
The object orientation in PHP is somehow…I don’t know, it feels like just a bad extension.
The really bad thing about this was, that it was used as a feature in T3Blog…But that is a different story.
(Addendum April 3, 2011: This blog isn’t based anymore on T3Blog – I never got it to work like I wanted it, especially the integration with TemplaVoila! was extremely difficult. I have now chosen a different solution here…)
Share this post
Twitter
Facebook
Reddit
LinkedIn
Email