PHP creating dynamic objects and php.ini settings

176 views Asked by At

I have a strange problem with creating dynamic objects.

On my local server with PHP 5.3.10-1ubuntu3.8 this code works fine:

$sObjName = 'field_xyz';
$o = $oVendor->{$sObjName};
print_r($o);                //prints the object "$oVendor->field_xyz"

But on my live server with PHP 5.3.13 the same code doesnt work. I cant create a dynamic object.

This code also doesnt work on my live server:

$oVendor->$sObjName

Otherwise this code works on both servers:

$a = "Hello";
$$a = "World";
echo "$a ${$a}";      //prints out "Hello World"

I would guess that this is a php.ini setting problem but I really dont know.

Local Server vs: Live Server

Local:

  • Real Server
  • PHP 5.3.10-1ubuntu3.8
  • Suhosin Patch 0.9.10
  • Apache/2.2.22 (Ubuntu)

Live:

  • Virtual Server
  • PHP 5.3.13
  • No Suhosin
  • Apache/2.2.16 (Debian) PHP/5.3.13 mod_ssl/2.2.16 OpenSSL/0.9.8o
0

There are 0 answers