PHP Tutorial PHP Blank page reasons and solutions

Source: Internet
Author: User
Tags php programming php syntax error blank page

A summary of the causes and workarounds for blank pages in PHP.

Many programmers in the development of PHP have encountered the appearance of blank pages, comprehensive analysis, in PHP Programming in a blank page may be caused by the following several reasons:

1. Logic Error
Logic errors are the hardest to rule out, and on the face of it, perhaps the code is legitimate and formal, but it is not expected to work. This is mentioned in many PHP tutorials.
Why is it? Perhaps the writer does not want to be comprehensive, after all, people are human, computer is a computer, the computer can not completely follow the people's thinking to run the script.
A good debugging method is to use the annotation "/* * * * *", commented out some code, observe the operation, so as to eliminate the error one by one, and finally find the location of the error code. In this case, to completely eliminate the logic error, no patience is not possible, so to calm down, do not worry.

2. Behavior not defined
Code:

<?PHP$action=$_get[' ID '];if($action= = "')$action= 1;if($action= = 1) {Echo("/$action' s value is 1 ");} Else if($action= = 2) {Echo("/$action' s value is 2 ");} //www.jbxue.com?>

If the $action variable is empty, set it to 1 and then determine the value of the $action variable to make a different event. Of course, if $action is neither equal to 1 nor equal to 2, what will PHP do? The answer is--nothing is done, so a blank page is created. Knowing the reason, the solution is easy.

The solution to this problem is simple, add an else after the If module, you can print some information.

3. Syntax error
If there is a syntax error, there is usually an error, how can it be blank? (Script Academy Www.jbxue.com)
Of course, this is only some of the individual phenomena, in some of the homepage space, if you write PHP syntax error, it will not have any hint.

Solve:
Before uploading the file, test it locally and find out the wrong code to correct it.

4. Misuse of the error mask @
The error suppressor "@" is often used in places where errors may occur, but the use of the suppressors is too much or is not a good time to use, and can also cause whitespace to avoid appearing, take a look at the following two PHP scripts:
test1.php:

<? php@ include ("test2.php"); Echo ($var);? >

test2.php:

<? PHP $var // This line of code has errors, no semicolons $var 1 // ditto ?>

Run the test1 look, and the result is a blank page. Correcting is also simple, you can remove the suppressors in front of the include function, or correct errors in the test2.php file.

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.