First stage PHP basics. Recursion and Constants

Source: Internet
Author: User

A beginner of PHP's accompanying notes, record their growth!

I. Recursion
1. Recursion: When the A function is called, and the A function calls the B function
The A function and the B function are the same function

2. Variable function: Assigns the function name to the variable, while the utility variable
parentheses, that PHP engine can parse functions normally

3. Function library
Arguments parameters
(1) Func_num_args: The number of arguments to get the function
(2) Func_get_args: An array consisting of the values of the parameters of the obtained function
(3) Func_get_arg: Gets the value of the function's argument as an array of values
Numbering starting from 0
(4) Function_exists: Determine if a variable is a function

4. Scope of variables (scope)
(1) Local variables: variables are valid only in the declared code snippet
(2) Global variables: variables are valid in any range, if
function must be declared in order to be valid
Global
$GLOBALS
(3) Super Global variables: variables are valid in any range, and
Do not declare variables
Description: All pre-defined variables are super global variables

(4) Pre-defined variables
$_post: Accept Form ' POST ' transmission mode,
stored in $_post by name and value
$_get: Accept Form ' GET ' transmission mode,
stored in $_get by name and value
$GLOBALS: Declaring global variables
$_files: Accept the information that the form uploads
$_session: Session mechanism
$_cookie: Session mechanism
$_request: Equivalent to $_post,$_get,$_cookie
The way to accept
$_server: Server information
$_ENV: Environmental Information

Description
(1) All pre-defined variables are super global variables
(2) Predefined variables are stored in an array form
For example
Print_r ($_post) accepts forms in the form
All of the information in
echo $_post[' user '] get a value


5. Constants:
5.1 Custom Constants
(1) Constant: The amount of the program can not be changed is called constant,
Constants once defined cannot be changed (cannot be re-assigned)
(2) Declaring constants
A. Define (' Constant name ', ' value ');
B. const constant NAME = ' value ';(used in object-oriented, class)
(3) Designation of constant name
A. Constant name as far as possible uppercase
B. Constant name does not have $
C. Constants are scalar types
D. Constants are super global variables except for const (scopes in classes and subclasses)
(4) Output of constants
A.ECHO constant name;
B. Echo constant (' constant name ');

5.2 System Constants
Php_int_max Integer Maximum Value
Php_o
S Operating System
Php_version PHP Version
5.3 Magic Constants

__LINE__: Gets the line number of the current document
__file__: Gets the absolute path to the current document
__DIR__: Get the absolute path to the folder where the current document is located
__function__ Get the function name
__CLASS__: Get class Name
__method__: Getting the name of a method in a class
__NAMESPACE__: Getting namespaces

6. File Upload:
(1) Conditions in the form with a browse box
A. Transmission must be ' post '
B. Adding attributes and values to the form tag
Enctype=multipart/form-data
(2) Accept upload file information with $_files (stored as an array)
A. $_files[' browse box name ' [' Name ']
Upload file name
B. $_files[' Browse box name ' [' type ']
Upload file type
c.$_files[' Browse box name ' [' Tmp_name ']
Upload files on the server temporary file directory and name location
d.$_files[' Browse box name ' [' Error ']
Upload file error 0 means success
e.$_files[' Browse box name ' [' Size ']
Upload file size (default unit byte (byte) =2^8)
1025B = 1KB
1024KB = 1MB
1024MB = 1GB
(3) Place the temporary file directory and the name location of the server on the target location
Move_uploaded_file ($tmpname, $filename);

(4) Parameters related to uploading php.ini
A.file_uploads = ON/off
Upload on and off
B.upload_max_filesize=2m
Maximum upload file size
C.upload_tmp_dir
Set the temporary folder location for the server

(5) Error message
A. UPLOAD_ERR_OK value 0 upload Successful
B. Upload_err_ini_size value 1
Beyond PHP.ini Upload_max_filesize
The maximum value
...

(6) Include file functions
Include: Include alarm error when loading page failed (Warning)
But the subsequent code continues to execute
Require: The include report fatal error when loading a page fails (Fatal)
But the following code stops executing
Include_once: Do not load the same page repeatedly
Require_once: Do not load the same page repeatedly

(7) Multi-File upload
A. Name of the form element is named in array form
The file upload information obtained is a three-dimensional array
So to convert a three-dimensional array to index + association
The two-dimensional array

B. Name of the form element is named separately
The file upload information obtained is Association + Association
Two-dimensional arrays, different from single-file uploads
Multiple members are named for multiple-file uploads alone
Single file upload has a member,
So to index + associative two-dimensional array

7. Summary:
1. Variables
2. Data types (8 primary data types and 4 pseudo-types)
3. Data type Conversion
(1) Automatic conversion
(2) Forced conversion
A. Temporary casts
B. Permanent casts
4. Operators
(1) Arithmetic operators
(2) Join operator
(3) Assignment operator
(4) Comparison operators
(5) Logical operators
(6) Error suppressor
(7) Execute operator
5. Process Control Statements
(1) Conditional branching statements
(2) Cycle
6. Arrays
7. Functions
(1) System functions
A. type discriminant function library
B. Time-date function library
C. Library of Mathematical functions
D. character function library
E. Array function library
D. function function library
E. Variable functions
(2) Custom functions

8 uploads





























======================================================================
Local students
Terminal:
Su Root
Password: ycty2016
CD/Go to root directory
CD home into the home folder
ll Browse Directory Resources
R 4
W 2
X 1
Chmod-r 777 www to www maximum access rights


















First stage PHP basics. Recursion and Constants

Contact Us

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.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.