PHP 3: Talking PHP tags from the login interface

Source: Internet
Author: User
Tags php website

Original: PHP 3: Talking PHP tags from the login interface

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<?PHP
2 require_once('bookmark_fns.php');
3Do_html_header ("');
4
5Display_site_info ();
6Display_login_form ();
7
8Do_html_footer ();
9?>
What do you think of seeing this code? OK, I'll explain below one by one:
1) How PHP separates from HTML
Take a look at lines 1th and 9th, then
<?PHP

?>When PHP parses a file, it looks for the start and end tags, where the start tag is<php, the end symbol is?>, if you've ever used ASP, you'll remember<%%>They have a somewhat similar effect. 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<?PHP
2 if($IsFinished)
3  {
4?>
5  <Strong>Congrats on you!You finished the job!</Strong>
6<BR>
7<?PHP
8  }
9  Else
Ten  {
One?>
A<Strong>I'm sorry to hear. Go on doing it!</strong>
-<?php
-}
the?>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 very contrived, but for the output of large chunks of text, out of PHP parsing mode is usually more than the use of all the content Echo ()Or print ()The output is more efficient.

You can use four pairs of different start and end tags in PHP. Two of them, <?php?> and <script language= "PHP" > </script> 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<?PHPEcho "This is the first style" ?>

(2) Similar to JAVASCIRPT, can be thought

1<script Language="PHP">
2Echo "the second style, similiar with JavaScript.:)"
3</Script>

(3) Short mark type, can be thought

1<? Echo 'This is the third style'; ?>

Or

1   <?=expression?>This is a shortcut for "<? Echo expression?>"

(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 when PHP is compiled with --enable-short-tags options.
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 () are exactly the same in all respects except how to deal with failures. 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.

PHP 3: Talking PHP tags from the login interface

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