PHP scripts are completed without affecting the HTML output.

Source: Internet
Author: User
Tags switch case
PHP end script, but does not affect the HTML output. For example: & lt ;? Phpif (! Isset ($ _ GET ["id"]) |! Isset ($ _ GET ["code"]) {echo & nbsp; "& lt; title & gt; Registration Verification & lt; /ti PHP end script but does not affect subsequent HTML output
It may be a small problem.
For example:
 If (! Isset ($ _ GET ["id"]) |! Isset ($ _ GET ["code"])
{
Echo"Registration Verification";
Exit ();
}
Else
{
Echo"Registration Verification 1";
}
......
?>


For example, this script is in HTML. To determine whether there is data submitted by GET to output different titles.
There are scripts later, but if GET has no data, it is unnecessary to connect to the database later, so we want to end it.
But after the end, use exit or return, followed by HTMLAnd so on. what should I do?
------ Solution --------------------
Cannot exit ();
Instead, we should put the database connection in the else branch.
------ Solution --------------------
You can also include the php code in a separate file.
Just change exit (); to return;

------ Solution --------------------
This post was last edited by xuzuning at 12:57:32 and you can also write functions.
Structured programming is nothing more
If else
If elseif else
Switch case default
The alternative is
While break

I really don't like structured programming
Php5.3 has recovered support for goto, and the proper use is quite good.
Goto;
Echo 123; // not executed here
A:
Echo 'ABCD ';

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.