phpwarnings

Illegal string offset Warning PHP


I get a strange PHP error after updating my php version to 5.4.0-3.

I have this array:

Array
(
    [host] => 127.0.0.1
    [port] => 11211
)

When I try to access it like this I get strange warnings

 print $memcachedConfig['host'];
 print $memcachedConfig['port'];


 Warning: Illegal string offset 'host' in ....
 Warning: Illegal string offset 'port' in ...

I really don't want to just edit my php.ini and re-set the error level.


Solution

  • Please try this way.... I have tested this code.... It works....

    $memcachedConfig = array("host" => "127.0.0.1","port" => "11211");
    print_r($memcachedConfig['host']);