PHP warning cannot usage a scalar value as an array solution _php tutorial

Source: Internet
Author: User
Tags php error php error log
See some of these hints in the PHP error log:

[27-aug-2011 22:26:12] PHP Warning:cannot use a scalar value as an array in/www/hx/enjoy.php on line 14
[27-aug-2011 22:26:18] PHP Warning:cannot use a scalar value as an array in/www/hx/enjoy.php on line 14

Check the source program, probably like this:
Copy CodeThe code is as follows:
$arr _hx = $mem->get (' HX ');
if (! $arr _hx) {
$arr _hx[' a '] = ' B ';
$mem->set (' HX ', $arr _HX);
}

Basically understand that when the $mem->get does not get the value of the return is false, at this time $arr_hx is False, Boolean, and then use it as an array, resulting in such a hint. In fact, a variable is not defined in a situation, before the assignment to add a sentence $arr _hx = array () to solve the problem.

Check it out, like the following note:
Reference
It is important to note the conversion of the type:
If a variable name (such as a) has been defined as a non-array type, such as an integer, then a can be converted to floating point, string (or even object type), but not an array, or a[0]=1, which is wrong, and PHP will report such a warning " Cannot use a scalar value as an array ". Even if a is defined as a one-dimensional array, it cannot be converted to a high-dimensional array.

http://www.bkjia.com/PHPjc/324941.html www.bkjia.com true http://www.bkjia.com/PHPjc/324941.html techarticle See the PHP error log for some of these hints: [27-aug-2011 22:26:12] php warning:cannot use a scalar value as an array in/www/hx/enjoy.php on line [27-aug-2011 22:26:18] ...

  • Related Article

    Contact Us

    The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

    If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

    A Free Trial That Lets You Build Big!

    Start building with 50+ products and up to 12 months usage for Elastic Compute Service

    • Sales Support

      1 on 1 presale consultation

    • After-Sales Support

      24/7 Technical Support 6 Free Tickets per Quarter Faster Response

    • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.