3rd PHP Route-first day (PHP language Reference)

Source: Internet
Author: User
Tags php language

First, the basic grammar

(1) PHP tags

<?phpecho "Hello world!"; /When the file is pure PHP, it is best to remove the PHP end tag at the end//?>

(2) separating from HTML

Content that is outside the beginning and end of a pair will be ignored by the PHP interpreter. That is, the HTML tag and PHP code mix of the kind, like jsp,asp ... <p>this is going to being ignored by PHP and displayed by the browser.</p><? PHP echo ' While the is going to be parsed. ';  ><p>this'll also be ignored by PHP and displayed by the browser.</p>//using conditions, advanced separation <?php if ($expression = = True):?> This would show if the expression is true.<?php else:?> Otherwise this would show.<?php end if;?>

(3) Instruction separator, comment

PHP needs to end the instruction with a delimiter after each statement.

Note://OR/* ... * * * but, * * will match the nearest one, remember! Remember!

Second, type

PHP supports 8 types of raw data.

Four scalar types: Boolean (Boolean), Integer (int), float (floating-point, double), string (string)

Two composite types: Array (array), object

Two special types: resource (Resource), NULL (no type)

<?php$a_bool = TRUE;  A boolean$a_str = "foo";  A string$a_str2 = ' foo ';     a string$an_int = 12; An Integerecho GetType ($a _bool);  Prints Out:booleanecho GetType ($a _str); Prints out:string//If This is a integer, increment it by Fourif (Is_int ($an _int)) {$an _int + = 4;} If $bool is a string, the print it out//(does not print out anything) if (is_string ($a _bool)) {echo "string: $a _bool";} ?>

(1) Boolean Boolean type







3rd PHP Route-first day (PHP language Reference)

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.