Lexical structure 1. Case in PHP, keywords, function names, and class names are case-insensitive, but variable names are case-sensitive.
2. Semicolons, spaces, line breaks, curly braces in PHP, a semicolon represents the end of a statement. In general, spaces and line breaks have no practical meaning in PHP, but can improve the readability of your code. Curly braces represent a block of statements.
3. Comment PHP supports a variety of annotation methods. such as the shell annotation method (beginning with #), the C language annotation (starting with/*, ending with */end), C + + language annotation (starting with//). such as: 12345 # Shell Annotation Method/* C language Annotation Method *///C + + language annotation Method 4. Direct volume refers to data values, such as data, strings, that appear directly in the program.
5. Identifiers, variable names, function names, class names, and constant identifiers are names that are named for variable names, function names, and class names. Its initials are underscore and uppercase letters (ASCII 0x7f~0xff can also, but generally no one uses.) ), the initials can be made up of underscores, uppercase and lowercase letters, and digital 0~9.
The variable name begins with a dollar sign ($) followed by an identifier. ※ variable names are case-sensitive function names and class names that are directly composed of identifiers. ※ The function name and the class name are not case-sensitive PHP constants are defined by define. such as 1 define (' NAME ', ' Yutuo ');
6. Keyword key keywords have some of the following $HTTP _cookie_vars $HTTP _env_vars $HTTP _get_vars $HTTP _post_files $HTTP _post_vars ...
PHP Learning (2) data type
PHP has 8 types of data.
Four basic types: shape, float, string, and Boolean;
Two composite types: arrays and objects; two other types: resources and NULL.
1. Shaping is an integer that can be positive or negative. The usual range is:-2147483648 ~ 2147483647.
There are three types of notation: decimal, octal, and hexadecimal. It can use the function Is_int ($x) to test whether it is an integer.
Example: 12345678910
$a = 10; Decimal
$a =-10; Decimal
$a = 010; Octal
$a =-010; Octal
$a = 0x10; Hexadecimal
$a = -0x10; Hexadecimal
if (Is_int ($a)) echo $a; ...
PHP Learning (3) variables
In the previous article, the variable is an identifier prefixed with the dollar sign ($). such as: $name. Variables can hold any type of value, and in PHP there is no syntax to declare variables. The first time a variable is used, the variable is created.
1. Variable variable variables, that is, a variable name exists in another variable, such as: $name = ' value '; $ $name = ' 1234 '; Once executed, a $value variable is created with a value of ' 1234′ '. 2. Variable references in PHP, variables are similar to pointers. The variable reference indicates that the two variables are pointing to the same value, and the alias has the same meaning. Because it points to the same address, changing the value of one of the variables will change the other variable. It is important to note that resetting a variable does not change another variable, because resetting the variable simply points the variable to null, without modifying the value pointed to by the other variable.
Both the parameter of the function and the return value can be a variable reference, which prevents large data types (such as strings, arrays, classes) from being copied.
Example code:
12345678910111213141516171819//Change the value of one of the variables
$value _a = ' Test ';
$value _b = & $value _a;
$value _b = ' change ';
print "\ $value _a is $value _a";
print "\ $value _b is $value _b"; ...
PHP Learning (4) expressions and operators
A PHP expression is a statement that calculates the result by a certain operator. PHP's operators are basically from the C language and the Perl language for reference.
1. Implicit type conversion digital calculation (add, subtract, multiply, divide, balance, etc.), first convert the string into a number, if the number is converted to a floating point or the expression contains floating-point number, then other numbers are converted to floating point to calculate, otherwise the integer is calculated. strings are computed (string concatenated), the numbers are converted to strings and then concatenated.
2. Increment and decrement increments and decrements can be placed before or after a variable. Put in front of the variable to indicate the first plus (minus) 1 recalculation, put in the variable after the first calculation plus (minus) 1
3. Type conversion Type the turn operator has some synonymous operators. For example: (int) and (integer), (float) and (real), (bool) and (Boolean) appended: The following table lists the operators of PHP, where "priority" is a large-to-small (high priority) representing the precedence of the operator; "Associativity" Indicates whether the operator is left-associative or right-associative ("No" means no associativity).
Precedence associativity operator Description 19 No new created object 18 right [] array subscript 17 Right! , ~ logical inversion, bitwise anti-Rightist ++,– increment, decrement right (int), (double), (string), (array), (object) type conversion right ...
PHP Learning (5) Flow control statements
In PHP, flow control statements consist mainly of conditional statements and loop statements. Flow control statements have if/else and switch statements, and loop statements have while and for statements.
1. If statement in PHP, the IF statement has two syntactic structures. A curly brace represents a statement block, a colon that represents a statement block. The former is typically used in pure code, which is typically used when code and HTML are combined. The two are written as follows: 1234567891011121314151617//curly braces denote statement block if ($value) {//operation;} elseif ($value) {//operation;} else {//action;}//Colon for statement block if ($value)://operation; ElseIf ($value)://operation; ELSE://operation; endif ...
PHP Learning (6) contains code and embedded PHP
Contains code in PHP, containing code with four functions, including include_once require require_once.
The main difference between include and require is that if the file does not exist, the require function throws a fatal error, and the include only throws a warning.
Include include_once and require require_once, where a suffix of once indicates that the file is not referenced again if the code already contains the file. Embedded PHP in HTML embedded PHP has four ways: XML form, SGML form, ASP form, script form. Where the ASP form is not supported by default, you must modify the Asp_tags to on in the PHP configuration file [PHP.ini].
The four methods sample code is as follows: 123456789101112//XML form
Echo ' Hello, world ';
?>
SGML Form
Echo ' Hello, world ';
?>//ASP form
<%
Echo ' Hello, world ';
%>
Script form
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.