I. PHP annotation Method
1. // (single line comment) 2./**/(multi-line comment) 3. # (mostly for Unix SHELL) 2. Embedding Method
You can specify it by yourself. Generally
<? Php...?> // Recommended <?...?> <Script language = "php">... </script> <%... %> 3. Reference File
Include and require
1. include is mostly used in Process Control to simplify the process.
Include ("myshortdefile. php") 2. require is often used at the beginning of a program. After being loaded, it becomes part of the program.
Require ("MyRequireFile. php") 4. Variables in PHP
1. variable name conventions
(1) variables in php are case sensitive.
(2) The variable name must start with the dollar sign $
(3) variable names can start _.
(4) variable names cannot start with numbers
$ Mystring = "I Am a string"; $ NEWLINE = "NEWLINE"; $ int1 = 38; 5. Data Type
1. scalar Data Type
(1) boolean
<? Php $ foo = true; echo $ foo;?> The output result is 1.
<? Php $ foo = false; echo $ foo;?> The output result is null.
(2) integer
<? Php $ int1 = 5; echo $ int1;?> (3) float is also called double
<? $ Dou = 123.456; echo $ dou;?> (4) string
<? $ Str = "Welcome To BeiJing"; // more than one word uses double quotation marks $ str2 = 'prometheus '; // only one word is enclosed in single quotes $ k = <SQL select * from news where news_id = 10 order by news_id desc SQL; echo $ k. "<br>"; // The Delimiter is used to keep the string format of multiple rows echo $ str. "<br>"; echo $ str2. "<br>";?> Check variable type
<? $ Str = "Welcome To BeiJing"; // more than one word uses double quotation marks $ str2 = 'prometheus '; // only one word is enclosed in single quotes $ k = <SQL select * from news where news_id = 10 order by news_id desc SQL; var_dump ($ k ). "<br>"; // The Delimiter is used to keep the format var_dump ($ str) of strings of multiple rows ). "<br>"; var_dump ($ str2 ). "<br>"; $ int1 = 5; var_dump ($ int1 ). "<br>"; $ dou = 123.456; var_dump ($ dou ). "<br>";?> Global variable scope
<? $ A = 10; $ B = 20; function test () {global $ a, $ B;/* defines $ a and $ B as global variables to function TEST, if no global variable is defined, 0 */echo $ a + $ B;} echo test ();?> 2. Composite data types
(1) array
(2) object
3. Special Data Types
(1) resource
(2) NULL
This article is from the "PHP Study Notes" blog