PHP syntax structure

Source: Internet
Author: User
Tags echo date

PHP Document composition


Html/xhtml Mark

CSS Styles

Client-side scripting (such as JavaScript, jquery, etc.)

Server script: <?php echo date (' y-m-d ')?>


A PHP file must contain server scripts, but not necessarily other types of code.


PHP syntax


When parsing a file, the PHP engine looks for the fact and end tag, which tells the PHP engine to start and improve the code between the two. This parsing allows PHP to be embedded in a variety of different documents, and any outside of the start and end tags will be ignored by the PHP parser.


XML style

<?phpheader ("Content-type:text/html;charset=utf-8"); echo "Hi PHP, I can conquer you!";? >

If no other content exists after the PHP code, then the end tag can be omitted and the omission is advocated.

<?phpheader ("Content-type:text/html;charset=utf-8"); echo "Hi PHP, I can conquer you!"; /script ends with no PHP end tag


Short style

<?header ("Content-type:text/html;charset=utf-8"); echo "I am short style";

Only the Short_open_tag configuration command in the PHP configuration file is activated to use the short style


ASP style

<%header ("Content-type:text/html;charset=utf-8"); echo "I am ASP Style";%>

Only the Asp_tags configuration command in the PHP configuration file is activated to use ASP style


Scripting style

<script language= "PHP" >header ("Content-type:text/html;charset=utf-8"); echo "I am Script style"; </script >


Comments


PHP supports C, C + +, and Unix shell style (Perl style) annotations.

The comment types for PHP are:

-Single line Comment

That only one line of code can be commented at a time

-Multi-line Comment

That is, you can annotate multiple lines of code at a time


Single-line Comment

C + + style annotations

Comment Content

Shell style annotations

#注释内容


Multi-line comments

<?php/*............*/

Note: When using multi-line annotations, you cannot let annotations fall into a recursive loop

This article is from the "rime" blog, please be sure to keep this source http://kinrey.blog.51cto.com/10492082/1834628

PHP syntax structure

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.