What to learn to get started with php

王林
Release: 2023-02-25 17:44:02
Original
2617 people have browsed it

What to learn to get started with php

Some basic knowledge for getting started with PHP learning

1. PHP script code tags

PHP The script is the content included in a pair of special tags in the file, such as "<%....%>" for ASP and "" for PHP. However, in order to adapt to the XML standard to embed PHP into XML or XHTML, PHP does not recommend using the short form "", but recommends using the long form tag "php...?>".

2. PHP command delimiter

Each statement in PHP needs to be separated by a semicolon ";", but for the PHP end mark "?>" Say, since it automatically implies a semicolon, there is no need to append a semicolon.

3. PHP comments

PHP multi-line comments use "/* ......... */" single-line comments use "#" or "//"

4. PHP output

In ASP, use "<%=...%>" to quickly output a single line, or use "< ;%Response.Write("...")%>". But in PHP use "echo()" or "print()" directly.
But this is impossible in ASP, especially when echo "a"; and echo d; are both output as strings themselves. This requires understanding PHP variable definitions.

5. PHP variables

Like ASP, PHP variables can be used directly without defining them first. The type of the variable is automatically generated when assigning a value. Various variables in PHP are distinguished by adding "$" before the variable name.

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

echo "$a" outputs the value of variable a, and echo '$a' outputs is the string itself in single quotes. Therefore, it can be concluded that as long as the variables are in double quotes, they will be replaced; while those in single quotes will not be replaced.

If the content in double quotes needs to be escaped, use the "\" prefix, such as "\\", "\$", "\"".

ASP transfer to PHP Need to pay attention to:

1. It is easy to forget to write the separator comma ";".

2. The definition and use of variables. 3. The usage of single quotes and double quotes.

Recommended tutorial: PHP video tutorial

The above is the detailed content of What to learn to get started with php. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template