PHP Fatal error: [] operator not supported for strings in…
After searching the information, I found that it was caused by the following reasons
When a variable is assigned a second time in the same page, but the inconsistent type of the value causes this error, the variable type can be declared again before the second assignment.
Simply put, it is the result of different types of assignments to the same variable on the same page.
Such as:
$a = “ABC”;
$a [] = “def”;
The solution
To check if your code has the way it was written in the above example, declare a variable once before each assignment or destroy it with the unset() function
Ex. :
$a = “ABC”;
unset($a);
$a [] = “def”;
After searching the information, I found that it was caused by the following reasons
When a variable is assigned a second time in the same page, but the inconsistent type of the value causes this error, the variable type can be declared again before the second assignment.
Simply put, it is the result of different types of assignments to the same variable on the same page.
Such as:
$a = “ABC”;
$a [] = “def”;
The solution
To check if your code has the way it was written in the above example, declare a variable once before each assignment or destroy it with the unset() function
Ex. :
$a = “ABC”;
unset($a);
$a [] = “def”;
Read More:
- ERR_CONTENT_DECODING_FAILED error occurs in PHP program, summary of solutions
- PHP link database error PHP_ network_ getaddresses: getaddrinfo failed: Name or service not known
- Three solutions to the appearance of notice: undefined index in PHP
- Parse error: syntax error, unexpected T_OBJECT_OPERATOR in E:\WWW\blog\hyii2\frontend\web\index.php
- An error is reported when executing MVN. The diamond operator is not supported in source-1.5
- PHP message: PHP Fatal error: Uncaught PDOException: SQLSTATE[08004] [1040] Too many connections
- Composer update encountered “Script php artisan optimize handling the post-update-cmd event returne when upgrading laravel
- php open(/var/lib/php/session/sess_4ofxxx, O_RDWR) failed: Permission denied (13)
- Fatal error in PHP project: class’ redis’ not found
- PHP – PHP Error[2]: Error while sending QUERY packet. PID=*
- PHP:Fatal error: Class ‘COM’ not found in … How to deal with the problem
- PHP try will also throw an exception if it is executed successfully
- Putty logs in and prompts no supported authentication methods available
- Matlab prompts undefined operator ‘*’ for input arguments of type ‘cell’
- A yellow warning appears on the pagecontroller page in PHP! ! ! !
- PHP & nbsp; built in server array
- An idea to solve Warning move_uploaded_file, failed to open stream in the process of php uploading files
- PHP function file_ get_ Contents() reports an error when using HTTPS protocol: SSL operation failed
- PHP Fatal error: Uncaught Error: Class ‘\Elasticsearch\Serializers\SmartSerializer‘ not found in /h
- PHP artisan cache: clear command reports an error