MindMap Gallery PHP basic LAMP website construction, HTML, CSS style knowledge framework
LAMP website construction.pptx, Chapter 1 PHP application and development details PHP version 4 Chapter Table of Contents 1.1 Introducing the Web to your understanding 1.2 Web components required for dynamic website development 1.3 Several mainstream Web application platforms 1.4 HTTP.
Edited at 2022-11-07 10:13:18This is a mind map about bacteria, and its main contents include: overview, morphology, types, structure, reproduction, distribution, application, and expansion. The summary is comprehensive and meticulous, suitable as review materials.
This is a mind map about plant asexual reproduction, and its main contents include: concept, spore reproduction, vegetative reproduction, tissue culture, and buds. The summary is comprehensive and meticulous, suitable as review materials.
This is a mind map about the reproductive development of animals, and its main contents include: insects, frogs, birds, sexual reproduction, and asexual reproduction. The summary is comprehensive and meticulous, suitable as review materials.
This is a mind map about bacteria, and its main contents include: overview, morphology, types, structure, reproduction, distribution, application, and expansion. The summary is comprehensive and meticulous, suitable as review materials.
This is a mind map about plant asexual reproduction, and its main contents include: concept, spore reproduction, vegetative reproduction, tissue culture, and buds. The summary is comprehensive and meticulous, suitable as review materials.
This is a mind map about the reproductive development of animals, and its main contents include: insects, frogs, birds, sexual reproduction, and asexual reproduction. The summary is comprehensive and meticulous, suitable as review materials.
PHP basic LAMP website construction, HTML, CSS style knowledge framework
LAMP website construction
Web, in web design, is called a web page. Web pages constitute a website, and a website is also software, which belongs to the type of Web system development with a B/S structure.
Web features:
1. Graphical
2. Platform independent
3. Distributed
4. Dynamic
5.Interactive
Advantages of the Web:
1. Based on browser, with unified platform and UI experience
2. No installation required, as long as you have a browser, you can use it anytime, anywhere
3. Always use the latest version of the application, no need to upgrade
4. Data is permanently stored in the cloud, so there is basically no need to worry about loss.
5. The new generation of Web technology provides a better user experience
Scripting language features:
1. Grammar and structure are usually simple
2. It is usually relatively simple to learn and use
3. Usually the "interpretation" of the program is easily modified as the running mode, without the need for "compilation"
4. Program development productivity is better than operational efficiency
Web components:
1. Client IE/Firefox/Safari and other browsers
2. Hypertext Markup Language HTML
3. Cascading Style Sheets CSS
4. Client-side scripting programming language JavaScript
5. One of the Web servers Apache/Nginx/TomCat/IIS, etc.
6. One of the server-side programming languages PHP/JSP/ASP, etc.
7. One of the database management systems MySQL/Oracle/SQL Sever, etc.
HTTP protocol overview
Hypertext Transfer Protocol
Is a standard for client and server requests and responses
URL overview
http://<IP address>/[port number]/[path]/[?<query information>]
http://www.baidu.com[:80]/images/index.php?id=2&name=fanbingbing
How the Web works
1. The server does not come with applications and databases
2. With application and web server
3. The browser accesses the server-side database
LAMP
Linux operating system Apache server MySQL database management system PHP background script programming language
HTML
Overview
Hypertext Markup Language
Consists of tags (attributes and entities) and content
Comments in HTML: <!-- .... -->
Syntax of HTML tags (tags): Tags are enclosed by "<" and ">"
Double tag: <tag name>....</tag name>
Single tag: <tag name/>
Colors in HTML:
Can be color words: red/blue/green/yellow...
It can also be: #000000 --- #ffffff
The first two digits represent red, the middle two digits represent green, and the last two digits represent blue.
Hexadecimal numbers include: 0123456789abcdef
the whole frame
HEADHead
The data contained in the header of most documents will not actually be displayed to readers as content. The header of the document describes various attributes and information of the document, including the document's title, location on the Web, and relationship with other documents.
The following tags can be used in the head section: <base>, <link>, <meta>, <script>, <style>, and <title>. <title> defines the title of the document and is the only required element in the head section.
BODY main body
text label
format tag
Hyperlink <a> tag
Image tag <img>
multimedia tags
table label
form tag
frameset tag
CSS styles
Syntax format: selector {property:value;property:value;property:value;....} Comments in CSS: /* ... */
How to use css styles in HTML (the way to embed css in html)
CSS2 selectors
CSS3 selectors
Common CSS properties
PHP
PHP is a hypertext preprocessor, which is executed on the server side and is a script embedded in HTML. PHP is an interpreted language (not compiled).
Installation and configuration environment
Get to know each other through a program
basic grammar
How to embed php into html:
1. <?php ... ?> Standard style (recommended)
2. <script language="php">....</script> long style
3. <? ... ?> Short style requires enabling the short_open_tag option in the php.ini configuration file.
4. <% ... %> is compatible with ASP style (not supported by default). You need to enable the asp_tags option in the php.ini configuration file.
In php, every statement ends with a semicolon. That is, the semicolon is the separator between PHP statements.
Comment
// Single line comments (comments from other programs)
# Single line comments (comments from scripts)
/* ... */ Multi-line comments Note: They cannot be nested.
/** .... */ Documentation comments
variable
PHP is a weakly typed language.
Variable naming convention:
Variables are defined starting with the $ symbol.
Rules for variable names: they must be composed of letters, numbers, and underscores, and cannot start with numbers.
Variable names in php are case sensitive
Release/destroy a variable
unset(); //Delete the value and address of a variable from memory
empty(); //It is used to determine whether a variable is empty. If it is empty, it is True otherwise False.
isset(); //Used to determine whether a variable exists, True otherwise False
There are a total of 8 basic data types in PHP:
4 scalar types:
integer(int)
PHP's integer type takes up 4 bytes (32 bits). And there is no negative sign
Stored value: -2147483648~2147483647
Floating point number (float/double)
There is no distinction between single precision and double precision, all occupying 8 bytes.
boolean
true and false
When converted to boolean, the following values are considered FALSE:
boolean FALSE itself
*integer value 0 (zero)
*Floating point value 0.0 (zero)
*empty "" string, and string "0"
*An array that does not contain any elements
An object that does not include any member variables (only applicable to PHP 4.0)
*Special type NULL (including variables that have not been set)
SimpleXML object generated from an XML document without any tags
string
Single quotes: ' ' does not support variable parsing, but supports the escape of single quotes ' and \.
Double quotes: " " supports variable parsing. For compatibility, use {} to enclose variables. (Supports escape: \s \t \r \" \\ \$)
Delimiter: <<< Pay attention to the use of the end character of the delimiter
2 compound types:
array
Multiple values can be stored in a variable. Arrays are divided into: associative arrays and indexed arrays
object
2 special types:
resources
NULL
Among them: object and resource types are reference types, and others are value types.
Type conversion problem
automatic type conversion
Converts to Boolean False in the following cases
false when boolean is false
0 When the integer bit is 0
0.0 or 0.00 When the floating point number is 0.0 or 0.00
"" When the string is empty
"0" When the string is 0
non-existent variable
In the following cases, it will be converted to numeric type
true will convert to 1
false will convert to 0
"123abc" will be converted to 123
In the following cases, it will be converted to string type
true will convert to "1"
false will be converted to ""
null will be converted to ""
cast
settype(); Format: settype(variable to be converted, "conversion type");
Simply put the type you want to convert in parentheses, followed by the variable you want to convert. You need to use a new variable to receive the result after conversion!
Define constants
Constant: A quantity that cannot be modified or destroyed again after being assigned a value is called a constant.
Features: Can be used in all subsequent programs (in objects, within functions...)
Format: define(constant name, value[,bool]);
For example: define("PI",3.14);
Use: echo PI;
Requirements: Constant names must be in all uppercase letters
Purpose: 1. Easy to remember 2. Easy to understand
Commonly used functions
operator
Arithmetic operators: - * / % (modulo/remainder) --
String operator . .=
Assignment operator = = -= *= /= %= .=
Comparison operators > < >= <= <> != == === !==
Logical operators: logical AND: and && logical or or || logical not not! Xor:xor
Both logical AND and logical OR have a short-circuit effect. (short circuit AND and short circuit OR)
Bit operators: & | ^ ~ << >>
Other operators: ? : `` @ => -> instanceof
ternary operator
expression? true and false;
operator precedence
If you can't tell the difference, use invincible()
process control
1. Sequential structure
From top to bottom, left to right
2. Branch structure
1>Single branch structure
if(conditional expression){ Condition is established: go to this range }
2> Bidirectional branch structure
if(conditional expression){ Condition is established: go to this range }else{ The condition is not true: move the interval }
3> Multi-directional branch structure 1
if(conditional expression 1){ Condition 1 is true: go to this range }else if(conditional expression 2){ Condition 2 is established: go to this range }else if(conditional expression 3)……{ Condition 3 is established: go to this range }else{ If none of the above conditions are true, go to this range }
4> Multiple branch structures 2
switch(variable){ case value 1: When the variable value is 1, the range to go break; case value 2: When the variable value is 2, the range to go break; … default: When all the above values do not exist, the range to go break; }
5>Nest-like branch structure
if(conditional expression){ if(conditional expression 1){ if(conditional expression 2){ } } }
3. Loop structure
1> while loop
while(conditional expression){ If the condition is met, execute the code here }
2> do…while loop
do{ Give it a try first, then ask: Do you accept it? }while(conditional expression);
3> for loop
for(expression1;expression2;expression3){ When the condition is met, the code is executed }
function
Definition: A function is a named, independent piece of code that performs a specified task and may return a value to the program that calls it.
Superiority:
1. Improve program reusability
2. Improve the maintainability of software
3. Improve software development efficiency
4. Improve software reliability
5. Control the complexity of program design
function declaration
Syntax format: function function name ([formal parameter 1, formal parameter 2,..., formal parameter n]){ function body; return return value; }
function call
Function name ([actual parameter 1, actual parameter 2,..., actual parameter n]); If there is a return value, you can use a variable to accept the return value. $a=function name([actual parameter 1,actual parameter 2,...,actual parameter n]);
function return value
The return statement can return any value determined in the function body to the function caller.
Returns program control to the caller's scope, i.e. exits the function. If a return statement is executed in a function, the statements following it will not be executed.
variable scope
local variables
Also called internal variables, they are variables declared inside a function. Their scope is limited to the inside of the function. It is illegal to use such variables after leaving the function. (Formal parameters are also local variables)
global variables
Also known as external variables, they are variables defined outside the function, and their scope ranges from the place where the variable is defined to the end of the program file.
PHP functions are independent code segments. To use global variables in a function, you need to use the global keyword.
You can also use $GLOBLAS instead of global
static variable
Within the function, variables defined using the static keyword (static storage type)
The first time the function is called, the variable is initialized. When called again, it will not be initialized again, but directly go to the memory space to obtain the previously stored result.
Function type
1. System functions
Examples: var_dump(), is_bool(), is_string(), gettype()
2. Custom functions
Functions with regular parameters
Format: string example(string name,int age, float height)
Functions with pseudo-type parameters
Format: mixed funName(mixed $args)
Functions that reference parameters
Format: void funName(array &arg) #Formal parameters that appear & are described in the parameter list
function with default parameters
Format: mixed funName(string name [,string value [, int expire]] #The parameters described by [] appear in the parameters
variadic function
Format: mixed funName(string arg1 [string ...] #Parameters described by... appear in the parameter list
Callback
variable function
Format: mixed funName(callback arg) #Use pseudo-type callback description in parameter list
recursive function
array
Classification of arrays: According to the subscript (index value) type of the array, it is divided into:
Indexed array: The array subscripts are all integers. The default array index subscripts start from 0.
Associative array: The array subscript is represented by a string (some other strongly typed languages call this a set)
The definition of array in php:
(1). Direct assignment: $array name[subscript]="value";
(2). Use array language structure to define.
(3) Use shortcuts to define arrays. (>=PHP5.3.0)
(4) Multi-dimensional array: When the element unit in an array is still an array, it is called a multi-dimensional array. (How many layers are how many dimensions)
Array traversal (iteration) output (4 types)
1. Use loop structures: for/while/do...while A function is used: count()--gets the length of the array (number of elements)
2. Use foreach to traverse an array Format: foreach (traversed array as [key =>] value) { .... }
3. Combine while each reset list to traverse the array (semi-automatic method) each()--Get the key and value of the current array pointer position, and return it in two ways: association and index, and move the pointer down one bit. reset()--Move the array pointer to the first position. list()--directly parses the value corresponding to the index subscript in the assigned array, and the parsing starts from 0 (Like array() , this is not a true function but a language construct. list() assigns a value to a set of variables in one operation.)
4. Use the following function to traverse the array (traverse the array manually) reset()-- Point the internal pointer of the array to the first element end() — Set the internal pointer of the array to the last element next() — Move the internal pointer in the array forward one position prev() — Rewind the array’s internal pointer one position current() — Returns the current element in an array key() — Get the key name from an associative array
Superglobal array:
$GLOBALS contains all of the following information
*$_SERVER server and execution environment information
*$_GET Array of variables passed to the current script via URL parameters.
*$_POST Array of variables passed to the current script via the HTTP POST method.
*$_FILES saves file upload information (detailed in the file processing chapter)
(Cookies and sessions are discussed in detail in the session tracking chapter)
*$_COOKIE An array of variables passed to the current script through HTTP Cookies (used to store login information for forums, libraries, blogs, etc.)
*$_SESSION An array of SESSION variables available to the current script. (Information storage for website shopping carts, etc.)
*$_REQUEST includes get, post and cookie
$_ENV stores system environment variable information
*$_SERVER["HTTP_REFERER"]--URL address of the previous page
--Host name of the server
*$_SERVER["SERVER_ADDR"]--The IP address of the server
$_SERVER["SERVER_PORT"]--server port
*$_SERVER["REMOTE_ADDR"]--Client IP
$_SERVER["DOCUMENT_ROOT"]--The web directory path of the server
*$_SERVER["REQUEST_URI"];//--URL address
echo $_GET["name"];
echo $_REQUEST["name"]; //Getting information will be slower than getting it above
Array related functions
1. Operation functions for array keys and values
*array_values — Returns all values in an array
array_keys — Returns all keys in an array
array_flip — swap keys and values in an array
*in_array — Check whether a value exists in an array
array_reverse — Returns an array with the elements in reverse order
*is_array() -- determine whether it is an array
2. Statistical correlation functions of arrays
*count -- Count the number of cells in an array or the number of attributes in an object
array_count_values -- Count the number of occurrences of all values in the array
array_unique -- Remove duplicate values from an array
3. With callback function
array_filter -- Use a callback function to filter elements in an array
array_walk – applies a user function to each member of an array
array_map -- apply the callback function to the cells of the given array
4. Sorting of arrays
*sort -- Sort the array (ascending order)
rsort -- sort an array in reverse order (descending order)
asort -- Sort an array while maintaining index relationships (associative array sorting)
arsort -- Sort an array in reverse order while maintaining index relationships
*usort – Sort values in an array using a user-defined comparison function
uasort – Sort values in an array using a user-defined comparison function and maintain index association
ksort -- Sort an array by key
krsort -- Sort an array in reverse order by key name
uksort -- Sort keys in an array using a user-defined comparison function
*natsort -- Sort an array using the "natural sorting" algorithm
natcasesort -- Sort an array in a case-insensitive manner using the "natural sort" algorithm
array_multisort – Sort multiple arrays or multidimensional arrays (understand)
array_slice -- remove a segment from an array
array_splice -- remove part of an array and replace it with another value
array_combine -- Create an array with the values of one array as its keys and the values of another array as its values
*array_merge -- merge one or more arrays
array_intersect -- Calculate the intersection of arrays
array_diff -- Calculate the difference of arrays