构造函数中的对象初始化(php 5.5)

Update: the problem is related to compilation, if I compile with disable-all then the code works as expected. Strangely, only post 5.3 versions are affected. I will recompile the latest version a number of time, adding just one --enable-* at a time to find out what causes the problem and then will post the result.

I'm trying to migrate to php 5.5 and can't find a way round the simple thing, discribed many times but in different context.

I'm getting

"Warning: Creating default object from empty value"

and I know that the workaround is to use stdObject, but it just doesn't work for me. Looks like I made a mistake somewhere, please help me.

I made a following code:

class MyClass {
   public $param;
   public function MyClass() {
      $this->param = "Param initialized";
   }
}
$myClass = new MyClass();
echo $myClass->param."
";

It gives me an empty line. I tried to add $this = new stdClass(); before param initialization, but it just hides the warning, "param" is still uninitialized.

I also tried to define constructor as __construct which gives absolutely the same result.

All I need is a simple example of object constructor which would initialize any attribute of the object being initialized.

Any ideas?

Update: Guys, this is the real code. First, desirable behavior with 5.3:

-bash-4.1$ cat tc.php
<?
    class MyClass {
        public $param;
        public function MyClass() {
          echo "in Constructor
";
          $this->param = "Param initialized";
        }
        public function getParam() {
          echo "in getParam
";
          return $this->param;
        }
    }
    $myClass = new MyClass();
    echo "1: ".$myClass->param."
";
    echo "2: ".$myClass->getParam()."
";
    ?>
-bash-4.1$ ../php-5.3.29/sapi/cli/php tc.php
 in Constructor
 1: Param initialized
 in getParam
 2: Param initialized
 -bash-4.1$

Now same code with 5.5 (same with 5.6):

 -bash-4.1$ ../php-5.5.30/sapi/cli/php tc.php
  in Constructor
  Warning: Creating default object from empty value in tc.php on line 9
  1:
  in getParam
  2:

Now code corrected to avoid warning:

-bash-4.1$ cat /export/home/csweb/CS/Activiti-Decta/CScripter/tc.php
 <?
  class MyClass {
     public $param;
     public function MyClass() {
       echo "in Constructor
";
       $this = new stdClass();
       $this->param = "Param initialized";
     }
     public function getParam() {
       echo "in getParam
";
       return $this->param;
     }
  }
  $myClass = new MyClass();
  echo "1: ".$myClass->param."
";
  echo "2: ".$myClass->getParam()."
";
  ?>
-bash-4.1$ ../php-5.5.30/sapi/cli/php tc.php
 in Constructor
 1:
 in getParam
 2:

And for sake of completance php 5.6

-bash-4.1$ ../php-5.6.14/bin/php tc.php
 in Constructor
 1:
 in getParam
 2:

Any suggestion how to get same results as in 5.3 with 5.5 or 5.6?

The problem was caused by wrong EXTRA_CFLAGS passed during the php compilation. Here is the one which worked:

export CPPFLAGS="-m64"; 
export EXTRA_CFLAGS="-m64";
make clean;
./configure --disable-all --disable-cgi --with-openssl --enable-json --with-oci8=instantclient,instantclient64_12_1/
make

And the one which produced php binary with such a strange behavior:

EXTRA_CFLAGS="-D_XPG4_2 -D__lint -m64 -DSIOCGIFNAME"

Why so many things were added to CFLAGS? Because I tried to complie with --with-sockets, which produced compilation errors, so I was trying to show gcc the way around. PHP compiled successfully and make tests shown no signs of problems.

Don't have a time or desire to continue digging, I'm happy now as system smoothly running on 5.6