PHP 3: Talking PHP tags from the login interface

Source: Internet
Author: User
Tags php website
This example is briefly described in the previous article.
OK, let's start with the login page of the first page.
Or look at the interface

How do you really want to guide it in the end is how to achieve it? OK, let's look at the code:

1 2 require_once (' bookmark_fns.php ');
3 Do_html_header (");
4
5 Display_site_info ();
6 Display_login_form ();
7
8 Do_html_footer ();
9?>


What do you think of seeing this code? OK, I'll explain below one by one:
1) How PHP is separated from HTML
Take a look at lines 1th and 9th, then


?>

When PHP parses a file, it looks for the start and end tags, where the start tag is , if you've ever used ASP, you'll remember <%%&gt, and they work a bit like that. These tokens tell PHP to start and stop explaining the code contained within these tags. With these tags, PHP ignores content outside of them. This allows them to be embedded in various documents, but the most common is embedded in HTML pages.
The above describes the most common HTML separation, then there is no more advanced? Of course. Examples are as follows:

1 2 if ($IsFinished)
3 {
4?>
5 < strong > Congrats on! You finished the job!
6 < br >
7 8}
9 Else
10 {
?>
< strong > I ' m sorry to hear. Go on doing it!
14}
?>

This example works correctly and the result is
I ' m sorry to hear. Go on doing it!
Because when PHP touches the end tag?>, it simply outputs the contents as it is, until it touches the next start tag. Of course, the above example is contrived, but for output chunks of text, it is usually more efficient to break out of PHP parsing mode than to use Echo () or print () output for all content.

You can use four pairs of different start and end tags in PHP. Two of them, and are always available. The other two types are short and ASP style tags that can be turned on or off in the php.ini configuration file. Although some people find it convenient to have short marks and ASP style tags, they are poorly ported and are usually not recommended. The above text is from the PHP website.
OK, to summarize, PHP tag has 4 kinds.
respectively:
(1). The above example is

1

(2) Similar to JAVASCIRPT, can be thought

1 < SCRIPT language = "PHP" >
2 echo "The second style, similiar with JavaScript.:)"
3

(3) Short mark type, can be thought

1

Or

1 This was a shortcut for " "

(4) ASP style, can think

1 <% echo ' asp-style tags '; %>
2 <%= $variable; # This was a shortcut for "<% echo ..."%>

In general, it can always be used, but the first looks more common.
As for the 3rd type, it is only available if the instruction Short_open_tag in the php.ini configuration file is opened, or the--enable-short-tags option is added at PHP compile time.
As for the 4th, it is only available if the instruction Asp_tags in the php.ini configuration file is opened.

Note: The above example has been tested and passed.
2) require_once

This problem is similar to the Include in C + +, the introduction of header files, but also similar to C # in the using Namespace,java in the import and so on. This is the introduction of the bookmark_fns.php file. But is it just this? No. It is similar to the Require () statement, except that if the code in the file is already contained, it will not be included again. Speaking, there are also 2 functions, include () and include_once (), require () and include () Apart from how to deal with failure in all respects is exactly the same. The include () generates a warning and require () causes a fatal error. In other words, if you want to stop processing a page when you lose a file, don't hesitate to use require (). The include () is not the case and the script will continue to run. Also be sure to set the appropriate include_path.

3) function
Here are 4 functions, namely:

Do_html_header (");

Display_site_info ();
Display_login_form ();

Do_html_footer ();

You may wonder where these guys came from. It does not matter, it can be understood, similar to the C language, require_once refers to the bookmark_fns.php header file, these functions are included in this header file. For example, but some of the names can not be called.
Let's talk about what these functions are for.
Do_html_header (") is the header used for the page. That is Phpbookmark.
Display_site_info () Displays the site information, which is the phrase "Store your bookmarks online with us!...".
Display_login_form () Displays the part of the login.
Do_html_footer () Displays the end of the page.
As to how they are defined, they are described in an article.

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