PHP_01 PHP overview, Data, syntax, php_01php overview syntax
1. Definition: PHP Hypertext Preprocessor, Hypertext Preprocessor, and server-side scripting language;
2. Environment: WAMP: Window + Apache + PHP + MySQL;
LAMP: Linux + Apache + PHP + MySQL;
Web server access: http: // localhost: 80 or http: // 127.0.0.1: 80
3. Syntax:
Common Errors: Parse error (parsing error) and syntax error (syntax error );
Eight data types: ① integer (int/integer), range:-2.1 billion ~ 2.1 billion, 0 ~ 4.2 billion; ② floating point type (float/double/real); ③ string (string), single-cited non-resolution variables, double-cited resolution; ④ boolean (bool/boolean), true/false; ⑤ array (array); ⑥ object; 7resource; null (NULL/null); declare and assign a value to NULL. The variable value is not declared as null, the value of the unset () deregister variable is NULL;
Constant: define (name, value); const NAME = VALUE; constant name cannot contain $;
System constant: PHP_VERSION: php version; PHP_ OS: runtime environment;
Magic constant: _ LINE _: Get the current row number; _ FILE _: Get the absolute path of the FILE including the FILE name; _ DIR _: Get the absolute path of the current FILE does not contain the FILE name;
Pre-Defined variables: $ _ GET: Form sending, address bar parameter passing, hyperlink parameter passing; $ _ POST: form receiving; $ _ REQUEST = $ _ GET + $ _ POST + $ _ REQUEST;
4. Data type conversion:
Implicit conversion: ① convert to a value: true-> 1, '31king'-> 31, 'true'-> 0; ② convert to a string: true-> string 1, false-empty string, numeric-numeric string; ③ convert to boolean false: 0/0. 0/'0'/null/empty array;
Forced conversion: ① parentheses (int), (string), (bool), (array )...; ② Function form: intval (), floatval (), strval (), boolval (); the variable itself is not affected;
Permanent conversion: The variable type will be changed; settype ($ val, $ type); set the variable type gettype ($ val); return the variable type
5. Commonly used:
Echo: the output string separated by commas;
Var_dump ($ var,...): prints variable details;
Unset ($ var,...): destroys a variable;
Header ('content-type: text/html; charset = utl-8 '): tells the browser encoding method;