关于Cannot use a scalar value as an array的解决办法
来源:互联网 发布:软件测试过程管理 pdf 编辑:程序博客网 时间:2024/05/16 02:16
今天在测试php程序的时候,出现了一个错误提示:Cannot use a scalar value as an array,这个错误提示前几天也出过,当时好像稍微调了一下就好了,也没深究,今天却又出现了。
不能再糊弄了,得找出原因和解决办法,于是我就去网上搜啊找啊,找了很久都没找到结果,不是网上搜不到这样的问题,而是很少有人做正面的准确的回答。最后这篇文章的一段文字让我一下子弄明白了怎么回事。
—————————————-
需要注意的是类型的转换:
如果一个变量名(如a)已经被定义为非数组类型,例如integer,那么a可以被转为floating point、string(甚至是object类型),但不可以是数组,即a[0]=1;是错误的,php会报出这样的警告“Cannot use a scalar value as an array“。即使a被定义为一维数组,也不能转为高维数组。
—————————————-
看到这句话之后,我仔细检查了一下代码,发现我上面已经定义过的一个布尔型变量在下面被我直接当数组来调用了,所以就出现错误了。
转自:http://blog.fesite.com/2009/08/22/cannot-use-a-scalar-value-as-an-array
这两天在改个游戏要把它放到手机上面去在看原代码时发现的这个问题。下次要在注意下了,原来的没有问题,要再留意下了。
- 关于Cannot use a scalar value as an array的解决办法
- 关于Cannot use a scalar value as an array的解决办法
- php下关于Cannot use a scalar value as an array的解决办法
- PHP警告Cannot use a scalar value as an array
- Cannot use a scalar value as an array?
- PHP Cannot use a scalar value as an array 的报错
- PHPWarning: Cannot use a scalarvalue as an array in /www/hx/enjoy.php on line 14
- 27. Given an array and a value
- json_decode(Cannot use object of type stdClass as array)
- PHP“Cannot use object of type stdClass as array”
- PHP“Cannot use object of type stdClass as array”
- Codeigniter Cannot use object of type stdClass as array
- PHP“Cannot use object of type stdClass as array”
- Cannot use object of type PHPExcel_RichText as array
- Cannot use object of type stdClass as array
- php 错误cannot-use-object-of-type-stdclass-as-array
- Cannot use object of type stdClass as array
- 关于run a dll as an app的问题
- Excel中无法插入和黏贴图片的解决方法
- 根据表名生成insert和update字段列表
- C#中class与struct的区别
- 定时调度带输出变量的存储过程
- linux:dpkg:依赖关系问题使得 skype 的配置工作不能继续:问题解决方法
- 关于Cannot use a scalar value as an array的解决办法
- linux:软件安装命令
- 我常去的编程技术网站
- VFS对象数据结构
- 忘了PostgreSQL数据库的密码的解决方案
- 最近感觉写代码写到入魔了
- 学习数据结构心得——1
- linux:无法获得锁的问题解决方法
- GM300写频软件的使用