PHP warning Cannotuseascalarvalueasanarray solution. For more information, see. The php error log contains the following prompts:
[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, which is probably like the following:
The code is as follows:
$ Arr_hx = $ mem-> get ('hx ');
If (! $ Arr_hx ){
$ Arr_hx ['A'] = 'B ';
$ Mem-> set ('hx ', $ arr_hx );
}
Basically, when $ mem-> get does not get a value, the returned value is false. $ arr_hx is false, a Boolean value, and then it is used as an array, this prompt is generated. In fact, it is also a case where the variable is not defined. Add $ arr_hx = array () before the assignment to solve the problem.
Check the following description:
Reference
Note the following type conversion:
If a variable name (such as a) has been defined as a non-array type, such as integer, a can be converted to floating point, string (or even object type), but cannot be an array, that is, a [0] = 1; is incorrect. php will report the warning "Cannot use a scalar value as an array". Even if a is defined as a one-dimensional array, it cannot be converted into a high-dimensional array.