I. Introduction of PHP
1.PHP
Meaning: hypertext preprocessor;
Advantages: Cross-platform (operating system), simple syntax, open source free.
Version: Latest PHP7, currently used for PHP5.6;
Second, the Environment construction/service Construction
Environment Construction: Operating system +web service + language + database.
1, the background language must be running on the server.
2, Web services: Apache, IIS, Tomcat;
3, the composition of the server:
1. Operating system (Linux) = more simple server Linux, development
Some more windows.
2.web Service: Apache
3. Language: PHP
4. Database: Mysql (open source free)
4. Server Setup: Manual setup, integrated environment (Wampserver,phpstudy,xmapp ... )
5. Location Environment: Phpstudy\www \wamp64\www\ Htdocs
How to access the name of the http:/server IP address.
eg:http://locallhost/http://127.0.0.1/http://192.168.1.121/
<?php?> is the beginning and end of PHP tags, all of the PHP code is written in the tag.
echo indicates the meaning of the output.
echo can only output numbers and strings.
Var_dump () can output variable details.
Comment: There is a single line comment//and # multiline comment is/**/
Good code habits: 1. Chinese sub-folder storage
2. Folder naming use English words, avoid Chinese
3. File naming also uses English words, and there are certain rules.
4. Variable naming, style naming, function naming using the Hump naming method
5. Front-end aspects: code structure. Do not use attribute abbreviations.
6.xhtml requires the label to end.
7. The code comment takes up one-third of the entire code.
6. Declaration of variables: $+ variable name = value
7.php and JS are weak type languages as well. You do not need to specify the data type of the variable.
The data type of the variable is determined by the appended value.
Naming rules for variables: numbers, letters, underscores, not numbers, you can use keywords
However, it is not recommended.
Types of variables: 4 (int), floating-point (decimal: float/double),
A string (String), Boolean (bool))
2 Composite types: Arrays (array), objects (object)
2 Special types: Resource (Resource), empty (null)
8. Strings are enclosed in double quotes and single quotation marks for the resulting content.
The difference between single and double quotation marks
Single quotes are output strings only and double quotes are output of variables and strings that can be parsed.
9. Process Control: Condition control: If,if...else, switch...case, Condition:
conditions are false; cyclic control.
10. Condition True/false, number, string, array, object, null ...
11. Increment, decrement
12. Custom Functions:
Function name () {
return value
}
13. Function Call: function name ()
The meaning of a function is to reuse it. Reduce the redundancy of your code.
A connector is a concatenation between a variable and a character.
A global variable cannot be referenced directly inside a function, only arguments are passed.
Precede its arguments with a & to indicate a pass-through value introduction. is the equivalent of an incoming address. To be tied together at the same time.
The pass value is equivalent to copy and paste, except the same value. It is not necessary to pass the & symbol into the function.
14. Declare an array of $arr=array ("A", "B")
Output arrays with Print_r ($arr) can output simple data types and can output complex
The data type.
Output is an array ([0]=>a[1]=>b[2])
0=>a: Key value pairs;
The array subscript can be a string, which is unique to PHP.
The array subscript is incremented by default from zero.
Subscript is the largest subscript from the previous number plus 1.
The subscript of an array can be a Chinese character.
foreach Loop: only works in the PHP array loop.
foreach (array to loop as Subscript = = value)
Is_array () Determines whether the array is not.
Second, the database
1. Warehouse where the data is stored.
2. Database classification: MSSQL,ACCESS,MYSAL,SQLSERVER,ORACLE,DB2.
3. Database Classification = "DATABASE =" table = "Data
4. The database we use: MySQL;
5.mysql Advantage: Open source free, storage millions other data.
6.appche The default port number is: 80;
MySQL default port number is 3306;
FTP default port number: 21;
Be sure to turn on database service when using MySQL database
How to access the database: Through the database management tool (phpmyadmin-system comes with
Navicat
7. Database operation steps: Log in database (database username and password: phpstudy default
As root and empty. )
Select or CREATE DATABASE = "Select the corresponding database double-click." = "New table.
8. Database data type: Similar to the variable type in programming.
There are two major types: numeric and string.
Digital type: Smallint,tinyint,int,bigint ...;
Double,float,decimal ...;
string: varchar (length 255), char (length 255), text (not qualified)
What is the difference between 9.varchar and char?
Are all types of strings, with a maximum length of 255 and a length when used.
At different points, varchar is longer; char is fixed length.
Determine data uniqueness, which is equivalent to id=> auto-increment, unsigned, and not repeat after deletion.
Array of methods: Is_array (), In_array (), substr (), Explode (),
Implode ();
10. Timestamp: Time () format date; date () sets the default time zone.
Date_default_timezone_set (' Asia/shanghai '): Sets the default time zone;
Parameter passing.
$_post to pass the argument. The parameter is hidden in the header to be passed.
Get parameters are easy to use and have low security. Parameter pass size is small.
Post mode use a little trouble, single security is relatively high. The parameter pass size defaults to 8m;
Modify and add the usage.
MD5 set its format to a classified number.
12.MVC model layer, view layer, controller.
GET method to pass the parameter: $_get
Using a link, <a href= "**.php?x=y&m=n" ></a>
Using forms: <form method= "POST" ></form>
POST Mode parameter acquisition: $_post
Use table only son parameters: 1. Specify action=> in form to get the page, and jump page
2. Specify how the method=> parameter is passed in the fform, i.e. get or post
3. Specify the Name property of the form control = parameter name
13. Page load: include (), require ()
14. Determine if a variable is empty: empty (), Isset ()
15. Upload Image:
(1) Upload file: A. form must be specified ectype= "multipart/form-date" property. The
B.$_files is used to save the pre-worn information in an array.
(2) exit (); process terminates execution die (); process terminates execution.
Array
(
[profile] = = Array
(
[name] + 1.gif = "file name
[type] + image/gif=" denotes the document format
[Tmp_ Name] = C:\Users\b\AppData\Local\Temp\php4AA7.tmp
= "The temporary save location of the transferred file."
[ERROR] = 0
[size] = 8839 = "File size
"
)
Move_uploaded_file ($_files[' profile ' [' tmp_name '], ' upload/'
. $_files[' profile ' [' name ']); means to save the picture to the next file named
In the upload file.
Problems:
1. File upload format.
2. File size.
3. Duplicate file name.
The writing of the catalogue $path= ' upload/sss/';
File_exists ($path) to find out if this directory exists.
mkdir ($path, 777,true); Create a directory.
JS built-in object: Bom--window--location:window.location.href
History:window.heistory.back ()
Screen:window.screen.width
Navigator
dom:--html--header/body--
4.SESSION and cookies: A storage function for the program
5.session use: Open: session_start ();
Save: $_session[' variable name ']
Destroy: unset ($_session[' variable name ')
6. Even table query: SELECT * from ' table 1 ' INNER JOIN ' table 2 ' on
' Table 1 '. ' Field ' = ' Table 2 '. ' Field '.
Use of session A. Must be the same domain name.
B. The browser is missing after the word is closed.
C. must be in the same browser.
D. Valid for 24 minutes.
PHP Learning Notes