PHP Frequently Asked questions resolved

Source: Internet
Author: User

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

PHPSend 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

PHPSend 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 !

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.