Basic Syntax-PHP manual notes

Source: Internet
Author: User
Original: Basic grammar-PHP manual notes

PHP tags

If the file content is pure PHP code, it is best to remove the PHP end tag at the end of the file. This avoids having to accidentally add a space or line break after the PHP end tag, which causes PHP to start outputting these blanks , and there is no intention to output the script at this time. Of course, <?php the space before the start tag of PHP or the line break will still be output.

Advanced separation of conditions of use

The meaning of the following code is very easy to understand, the key is If-else usage, so use in the text output is explicit logic clearer.

<?php $expression = false; ?><?php if ($expression == true): ?>This will show if the expression is true.<?php else: ?>Otherwise this will show.<?php endif; ?>
Instruction delimiter

PHP needs to end the instruction with a semicolon after each statement, and the semicolon is called the instruction delimiter. The last line in a PHP code snippet can end without a semicolon.

Comments

PHP supports c,c++ and Unix shell-style (Perl-style) annotations, i.e. /**/ ,, // # .

A single-line comment only comments to the end of the line or the current PHP code block, which means that the // ... ?> # ... ?> HTML code will be displayed in or after. However, the </script> tag does not jump out of PHP mode in a single-line comment.

(End of full text)

Basic Syntax-PHP manual notes

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.