Skip to content


PHP Funny Behaviour

Today I found a small example of a php code that reminded me the endless battles between ruby/python and php folks stating how bad the php is. Well… let’s see the small example:

<?php
$ee = new e();
$ee->x();

print_r($ee);

class e
{
  function x()
  {
    print "run x()\n";
  }
}

running this returned no error, but instead the output is like this:

run x()
e Object
(
)

Yea… it seems that’s quite normal in the PHP world to instantiate an object of a class that is going to be declared later. And what’s more, the object is quite good :) wonderful.

Related posts:

  1. What is a Computer Programmer Wow, that is the kind of information I hit upon...
  2. Naming Convention aka PHP vs Python Is Python really better than PHP? I doubt, and in...
  3. Funny C++ Job Interview Some time ago I had an interview to a new...

Posted in programming.

Tagged with , .


0 Responses

Stay in touch with the conversation, subscribe to the RSS feed for comments on this post.



Some HTML is OK

or, reply to this post via trackback.



Better Tag Cloud