This article introduces the content of the PHP common problems solved, has a certain reference value, now share to everyone, the need for friends can refer to
problem
Display Chinese garbled?
Solve
Modify the source file to a UTF-8
format.
problem
Uncaught Error: Cannot use string offset as an array in...
cause
The array to be written does not exist and needs to be created
$arrays = $array ();
problem
Set $_SESSION
a variable to disappear after a page jump?
Solve
You need to $_SESSION
call session_start();
it every time you use it.
problem
After using the AJAX
access server, the URL bar adds a?
Open chrome
, press F12
Enter the source code, set a breakpoint, the program does not jump into the breakpoint, but re-refresh the page?
Solve
When using a form, you need to use:
<form> <label> Controller Debug Assistant:</label> <input type= "button" Name= "Submit_xghelper" value= "Download " onclick=" Ondownloadbuttonclick (' Xghelper ') "></form>
This format, if modified to:
<form> <label> Controller Debug Assistant:</label> <button onclick= "Ondownloadbuttonclick (' Xghelper ')" > Downloads </button></form>
The above situation will occur!
problem
PHP
Send JS
the JSON
format data, JS
JSON.parse()
when using parsing, chrome
prompt:
Uncaught syntaxerror:unexpected token? In JSON @ position 0 at Json.parse (<anonymous>) at XMLHttpRequest.xmlhttp.onreadystatechange ( download.php:84)
cause
File format error
Solve
Because of the background PHP
file, use:
Require_once ". /utils/config.php ";
Contains other files, the file format is: UTF-8 with BOM , you need to Ultra Edit
save the file as a UTF-8 format without BOM !
problem
Display Chinese garbled?
Solve
Modify the source file to a UTF-8
format.
problem
Uncaught Error: Cannot use string offset as an array in...
cause
The array to be written does not exist and needs to be created
$arrays = $array ();
problem
Set $_SESSION
a variable to disappear after a page jump?
Solve
You need to $_SESSION
call session_start();
it every time you use it.
problem
After using the AJAX
access server, the URL bar adds a?
Open chrome
, press F12
Enter the source code, set a breakpoint, the program does not jump into the breakpoint, but re-refresh the page?
Solve
When using a form, you need to use:
<form> <label> Controller Debug Assistant:</label> <input type= "button" Name= "Submit_xghelper" value= "Download " onclick=" Ondownloadbuttonclick (' Xghelper ') "></form>
This format, if modified to:
<form> <label> Controller Debug Assistant:</label> <button onclick= "Ondownloadbuttonclick (' Xghelper ') ) "> Download </button></form>
The above situation will occur!
problem
PHP
Send JS
the JSON
format data, JS
JSON.parse()
when using parsing, chrome
prompt:
Uncaught syntaxerror:unexpected token? In JSON @ position 0 at Json.parse (<anonymous>) at XMLHttpRequest.xmlhttp.onreadystatechange ( download.php:84)
cause
File format error
Solve
Because of the background PHP
file, use:
Require_once ". /utils/config.php ";
Contains other files, the file format is: UTF-8 with BOM , you need to Ultra Edit
save the file as a UTF-8 format without BOM !