The basic syntax of PHP

Source: Internet
Author: User

The syntax of PHP is very much like the C language.

1, PHP can be mixed with the HTML code, using the format:

<?php

Statement

?>

2, PHP code can also embed HTML code

3, can use JavaScript script to embed PHP code (not recommended)

Like what:

<script language= "PHP" >

echo "Hello";

</script>

4, if only to display the value of a variable, you can use the following methods:

<?= variable?>

Cases:

<title> My php file </title>

<meta http-equiv= "Content-type" content= "TEXT/HTML;CHARSET=GBK"/>

<body>

<?php

$i = 45;

?>

<br/> Results are: <?= $i?>

</body>

Show:

The result: 45

5, the PHP statement ends with a semicolon;

6. PHP is case-sensitive

7, PHP is a weak data type programming language, the type of variable is not fixed.

8. The PHP variable name begins with a letter or an underscore followed by any letter, number, or underscore.

9. When PHP defines variables, use the dollar sign $ identifier.

Cases:

$a = 600; Defines a variable named $a, and then assigns a value of 600 to the variable.

PHP file to run the error of several common English words meaning:

Parse: Parsing

Error: Wrong

Syntax: Grammar

Unexpected: Do not expect

Expecting: Expectation

Comments in PHP

1. Multiple lines of annotation:

/*

Code

......

*/

2. Comment Single line:

Code

#代码

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.