After updating my php version to 5.4.0-3, I'm getting a strange PHP error.
I have this array:
Array
(
[host] => 127.0.0.1
[port] => 11211
)
I get weird warnings when I try to access it like this
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 reset the error level.
Error
Illegal string offset 'whatever' in...Usually means: You are trying to use a string as a complete array.This is actually possible because in php strings can be treated as arrays of single characters. So you think $var is an array with keys, but it's just a string with standard numeric keys, for example:
$fruit_counts = array('apples'=>2, 'oranges'=>5, 'pears'=>0); echo $fruit_counts['oranges']; // echoes 5 $fruit_counts = "an unexpected string assignment"; echo $fruit_counts['oranges']; // causes illegal string offset errorYou can see the actual effect here: http://ideone.com/fMhmkR
For those of you asking this question and trying to turn false ambiguity into a solution, like me.
Please try this way...I have tested this code...it works...
$memcachedConfig = array("host" => "127.0.0.1","port" => "11211"); print_r($memcachedConfig['host']);