非法的字符串偏移量警告PHP [英] Illegal string offset Warning PHP

查看:100
本文介绍了非法的字符串偏移量警告PHP的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

将我的php版本更新到5.4.0-3后,我收到一个奇怪的PHP错误.

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

我有这个数组:

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 ...

我真的不想只编辑我的php.ini并重新设置错误级别.

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

推荐答案

请尝试这种方式....我已经测试了此代码.

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

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

这篇关于非法的字符串偏移量警告PHP的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆