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)