PHP syntax (1-4)

PHP Syntax

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

Basic PHP syntax

We useto mark PHP code snippets. They are used to mark where PHP code begins and ends. In this way we can insert various PHP codes into HTML. To achieve dynamic web page output, this is mixing. Text within the

tag is treated as PHP code. Text outside the tag is treated as normal HTML.

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 an example of a simple PHP file that can output the text "Hello World!" to the browser:

Example

   

My first PHP page

Everything in PHP Lines of code 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

     

Everyone should have learned html comments when learning html< !-- -->.

The so-called comments are comments made in the code to make it easier for people to read the code. Comments can be used to explain the purpose of the script, who wrote it, and why it was written that way. The PHP interpreter ignores all comments.

PHP has three comment methods

• /**/Used to comment large sections of multi-line text, generally used to comment functions, classes, or complex logic (C language style)

• // Used to comment a single line of text, generally just used to simply comment a certain line of code (C++ style)

• # The effect is the same // (SHELL script style)


A rough schematic diagram of the interpreter, easy to understand.

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!