Basic PHP learning basics for beginners

Source: Internet
Author: User
Tags echo d

Introduction: This is a beginner's Guide to some basic knowledge of PHP learning details page, introduced and PHP, related knowledge, skills, experience, and some PHP source code.

Class = 'pingjiaf' frameborder = '0' src = 'HTTP: // biancheng.dnbc?info/pingjia.php? Id = 323142 'rolling = 'no'>

Introduction: 1. php scriptsCodeThe script for marking PHP is the content of a pair of special tags in the file. For example, ASP is "<%... %>", PHP... 1, PHP script code mark
The PHP script is the content included in a pair of special tags in the file. For example, ASP is "<% .... %> ", PHP can be viewed as" <?...?> ".

However, to adapt to XML standards to embed PHP into XML or XHTML, PHP does not recommend the use of "<?...?>" in short format ", We recommend that you mark "<? PHP...?>"
In addition, the PHP code block supports the markup form of <script language = "php">... </SCRIPT>.

2. php instruction Separator

Each PHP statement needs to be separated by the Semicolon ";", but the PHP end mark "?>" Because it automatically implies a semicolon, you do not need to append the semicolon.
Therefore, the format of a PHP script is as follows:

3. php comments

PHP multi-line comment using "/*... */"

Use "#" or "//" for a single line comment

4. php output

Use "<% =... %>" in ASP to quickly output a single row, or use "<% response. Write ("... ") %>"

Directly use "echo ()" or "Print ()" in PHP, for example:

The output is "ABCD". All the above four types can be output normally.

However, in ASP, especially echo "A"; and echo D;, both are output as strings themselves, which is impossible. Therefore, you need to understand the definition of PHP variables.

V. php Variables

Like ASP, PHP variables can be directly used without being defined first. Variable types are automatically generated when values are assigned.

Various variables in PHP Add "$" before the variable name to show the difference.

Enter "A123"

6. The difference between single quotes and double quotes in PHP

The output is "123 $ A", where Echo "$ A" outputs the value of variable A, while echo '$ a' outputs the string itself in single quotes.

The output value "123 '123' is not" 123 $ ". Although it is '$ A', the variable placed under double quotation marks is still replaced.

Therefore, we can conclude that variables in double quotation marks will be replaced, while those in single quotation marks will not be replaced.

The content in double quotation marks must be escaped and prefixed with "\", such as "\", "\ $", and "\". Therefore, if you enter "123 $ ",

For example:

The output is "123 $ "\".

Notes for transferring ASP to PHP:

1. The separator comma ";" is easy to forget to write.

2. Definition and use of variables.

3. single quotation marks and double quotation marks. (Text/xingkongshuai)

More articles on "Basic PHP learning basics for Beginners"

Love J2EE follow Java Michael Jackson video station JSON online tools

Http://biancheng.dnbcw.info/php/323142.html pageno: 16.

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.