PHP Basic Syntax

Source: Internet
Author: User

Single-line Comment

/* * * Multi-line Comment

Output statement

1. Output string

print "Hello"; Only one string can be printed

echo "World"; You can print multiple strings at the same time. (a lot of use)

2. Output type (programmer test)

var_dump("AA"); You can also add variables

3. Output array

Print_r();

Weakly typed languages

You do not need to specify a type, all variables need to add $ sign

(string)$a to convert variable A to a string

settype($a, "string"); The variable A is converted to a string, and the return value is a Boolean value.

Defining strings

1. Double quotes:

$a = "Zhang San";

2. Single quotes:

$a = ' Zhang San ';

Attention:

A. The escape character can be parsed inside a double quotation mark.

$s = "Hello \" world;

Output

B. Double quotes can parse variables.

$s = "Hello {$a} world";

Output

Escape character: \ n for line break, \ r for carriage return, \ t tab, \ ", \ ', \ \

3.

$s 2=<<<A"Http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd" >A; Var_dump ($s 2);

Output Result:

Global variables

Var_dump ($GLOBALS);

Output Result:

Variable variable

$a = "Hello"; $hello = "Zhang San"; Echo $$a;

isset($a); determine whether a $ A is defined

var_dump(isset($a)); Output result Bollinger type

unset($a); Clear variables

Empty ($a); Determine if $ A is empty

0, empty string, NULL, False

& Address

$a = ten; $b = &$a; Echo $b;

Output 10

PHP Basic Syntax

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.