Why blank pages appear in PHP and how to solve _php tutorials

Source: Internet
Author: User
Tags php syntax error blank page
A blank page in PHP programming can be caused by 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. 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. Here, I tell you a better debugging method, is to use the comment "/* * * * * * * * * *", commented out some code, observe the operation situation. To completely eliminate logic errors, no patience is not possible, so to calm down, do not worry.
2. Behavior not defined
Look at the following code:
$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");
}
?>
This code is very clear, that is, if the $action variable is empty, set it to 1, and then judge 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?? --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
People may ask, if there is a grammatical error, there will be a general error, how can it be blank? Of course, this is only some of the individual phenomena, in some of the homepage space (such as the free space of Chinese network), if you write PHP syntax error, it will not have any hint. The solution is also easy, before uploading the file in the local test, find out the wrong code to correct it. (www.bkjia.com)
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
@include ("test2.php");
Echo ($var);
?>
test2.php
$var = "Hi"//This line of code has an error, no semicolon
$var 1 = "Hello"//Ibid.
?>
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.

http://www.bkjia.com/PHPjc/371501.html www.bkjia.com true http://www.bkjia.com/PHPjc/371501.html techarticle A blank page in PHP programming may be caused by the following reasons: 1, logic error logic error is the most difficult to exclude, from the surface, perhaps the code is legal, is formal ...

  • 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.