PHP Basic Syntax

Source: Internet
Author: User

JS is the script language of the previous paragraph

PHP is the back-end scripting language

First, the files are built to exist under the WAP www inside

Second, all the filenames cannot contain Chinese

Third, through the input localhost/www file name, you can browse

Iv. Create a new site within the DW, change the site folder location in www

V. Basics of PHP

PHP Tags:

<?php content? > can be embedded in PHP anywhere

<? Content? > Short mark, php one of

Comment Syntax for PHP:

Single-line Comment

/* Multiline Comment */

PHP is also a weakly typed language

Vi. Definition of variables

PHP has all the variables to add $ A: $a = 10;

Vii. output Syntax

PHP's output syntax:

1, Echo $a; Common output

2, print $a; can also output

Echo can simultaneously output multiple

Print can only output one at a time

3, Print_r (); a specially printed array

4, Var_dump (); Output variable information, used in error adjustment

3, 4 of the most used in debugging

Viii. ways to convert types

Type of cast variable a

$a = 10;

1, $a = (string) $a;        Converts an integer to a string of 2, Settype ($a, "string"); You can also convert the type of variable a

Nine, the definition of the string

3 ways to define a string:

1, $s = "hello";

2, $s = ' world ';

3, $s =<<<a

Write content in the middle, without quotes, for more content

A

End with a capital A, end a front is the head written, there can be no space or something else

The difference between single quotation marks and double quotation marks

The difference between a double quote and a single quote:

\ n escape characters, which can be wrapped in source code, but not wrapped in a Web page

1, double quotes inside can parse escape character, single quotation mark inside can not, will be output

Example: $ name= "Zhang San";

$s = "hello{$name}"; Parsing variables

Echo $s;

The last output will be Hello Zhang San

2, double quotation mark can parse variable, single quotation mark can not, will be output

Xi. stitching points for two strings

PHP, two strings stitching, use dot without plus sign

Example: $ name= "Zhang San";

$s = "hello". $name

12. Variable variable

Variable variable:

Cases:

$a = "Hello";

$hello = "Zhang San";

echo $ $a;

The result of the output will be Zhang San, only in PHP, you can use this syntax.


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.