23:
3. Notes
3.1 single line comment: // or # multi-line comment:/* Description */
More than 3.2 line comments cannot be nested, but can contain single line comments; single line comments can also contain multiple lines of comments. Just like this
1: <?php
2: // echo "test";/* a single line contains multiple line annotators */
3:/* echo 'test'; // contains a single-line annotator */
4: ?>
Iii. Variables
1. Use of Variables
1: <?php
2: $ a = 1; // declare a variable
3: $ B = "php"; // declare a variable B
4: $ 8d = 2; // invalid variable name. It can only start with a letter or underline and does not contain spaces
5:
6: $ I site is = "php"; // valid variable name, which can be in Chinese
7: /*
8: * The following three function call methods are equivalent.
9: * keywords and built-in functions and user-defined class names. The function names are case-insensitive.
10: */
11: phpinfo();
12: PhpInfo();
13: PHPINFO();
14:
15:
16: /*
17: * The following three variables are different.
18: * variable names are case sensitive
19: */
20: $name = "php1";
21: $Name = "php2";
22: $NAME = "php3";
23:
24: // variable: variable names can be dynamically set
25: $hi = "hello";
26: $$hi = "world";
27: // hello world is output below
28: echo "$hi $hello";
29: echo "$hi ${$hi}";
30:
31: // variable assignment
32: $ foo = "B" // value assignment
33: $ bar = & $ foo // reference value assignment
34: $bar = "LZ";
35: echo "$ foo"; // output LZ
36: $ cde = $ foo; // value assignment
37: $cde = "E";
38: echo "$ foo"; // output LZ
39: ?>
2. Variable type
Iv. Constants
1. Define and use
1: <?php
2: /*
3: *boolean define(string name,mixed value[,bool case_insensitive)
4: * name: constant name; value: constant value; the third value is an optional Boolean value. The default value is FALSE (Case Insensitive)
5: */
6: define("FLO",1000);
7: echo FLO; // output 1000
8:
9: // use the define function to check whether a FLO constant exists. If yes, the constant value is output.
10: if(define("FLO"))
11: {
12: echo FLO;
13: }
14: ?>
2. constants and variables
2.1 The scope of a constant is global. You can declare and access a constant anywhere in the script.
2.2 There is no $ before a constant, and a constant cannot be defined using a value assignment statement.
2.3 Once a constant is defined, it cannot be redefined or canceled until the script stops running.
2.4 The constant value can only be a scalar (a type in boolean, integer, float, string)
3. predefined constants of the system
4. Common magic Constants
Source: http://www.ido321.com/510.html
Basic php syntax
Double quotation marks are used to output strings. Example: echo "data insertion failed, error message: <br> ";
And "insert into testtable VALUES ('". $ xm. "',". $ nl. ")"; in insert into testtable VALUES is a string, which means to INSERT to the database, two "" are a group, put. $ xm. separated ,(. $ xm .) $ xm is a variable. echo is used when a variable is displayed in php.
The basic syntax of php and database has been basically mastered. How can I recommend a php book with a complete project ?? I really want to learn php well
PHP and MySQL Web development: the "php Bible". In comparison, "PHP with zero Infrastructure" is more suitable for beginners. It is easy to see that the author writes it with heart.
This book is actually one of the zero basic programming series, and others are quite good.
The content is well designed. There is a preface, which is very pertinent. It is the advice that programmers give to cainiao. The excerpt is as follows:
++ ++
Notes for learning programming:
1. do not stick to the Syntax: Many beginners try to memorize various syntaxes. In fact, this is extremely wrong. The syntax and norms of program development are too many to remember. You only need to know that such a function is available. yes, you can read books or search for help files when necessary, which saves time and effort.
2. Multi-handed and multi-exercise: people who only know books will not become masters of development. Only by writing programs on multiple computers can they improve their understanding of programming in practice.
3. if you encounter a problem, first try to solve it by yourself: if you try your best to solve it at the first time, you cannot find help again. Do not immediately seek help if you encounter any problem, which will never improve much.
4. Google and Baidu: The network is a large knowledge base and the best teacher. If you have any problems or other people have encountered them, search for them.
4. Read the source code of others more: Read the design ideas of others and continue to use them.
++ ++
The disadvantage of this book is that there is no line mark in front of the Code, while a large mistake is made when "xxx line," is widely used in the interpretation of the Code.
Summary: in terms of knowledge points, "no basic learning PHP" may be incomplete. However, what we need is not a dictionary. We need a well-intentioned book that we are interested in learning, isn't it?