php basic syntax

PHP Syntax

PHP scripts are executed on the server and the plain HTML results are sent back to the browser.

Basic PHP syntax

PHP scripts can be placed anywhere in the document.

PHP scripts start with :

The default file extension for PHP files is ".php".

PHP files usually contain HTML tags and some PHP script code.

Below, we provide a simple PHP file example, which can output the text "Hello World!" to the browser:

Example (1)

   

My first PHP page

Example ( 2)

   

My first PHP page

Example (3)

   

My first PHP page

Every line of code in PHP must end with a semicolon. A semicolon is a delimiter used to separate sets of instructions.

Through PHP, there are two basic instructions for outputting text in the browser: echo and print.

Comments in PHP

Examples

     

Notes:

Every code in PHP Lines must end with a semicolon. A semicolon is a delimiter used to separate sets of instructions.

Through PHP, there are two basic instructions for outputting text in the browser: echo and print.

In actual use, the functions of print and echo are almost identical.
It can be said that wherever one can be used, the other can also be used. However, there is still a very important difference between the two:
In the echo function, multiple strings can be output at the same time, while in the print function, only one string can be output at the same time. At the same time, the echo function does not require parentheses, so the echo function is more like a statement than a function.

echo is more efficient.

Continuing Learning
||

My first PHP page

submit Reset Code
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!