thesonix thesonix - 1 year ago 179
PHP Question

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:

[host] =>
[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.

Thanks for any help!

Answer Source

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

$memcachedConfig = array("host" => "","port" => "11211");
print_r ($memcachedConfig['host']);
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download