The Declaration of a function1. Grammatical structure
The code is as follows
Copy Code
function functions name (argument list){function body; Optionalreturn value; Return optional}
parameter list separated by
This article is mainly summarized for beginners who don't know anything about PHP features, so the demo code takes up more space. Let's see what you need to add. Welcome to the Mail or in Phpchina's "Phper" magazine section to correct the error. A
Using a custom function method to implement the 99 multiplication table, a function is a block of code that can be executed whenever it is needed.
To create a PHP function:All functions start with the keyword "function ()".Named function – the name
Programming environment
PHP5.2.4, basically PHP4.3 the above version, this code can be used
Preparatory work
Check Upload_tmp_dir items
If the PHP development environment is built on its own, you need to edit the php.ini file before you write
Converts the first letter of each word to uppercase: Ucwords ()Capitalize the first letter of a word: Ucfirst ()First letter to lowercase: lcfirst ()Capitalize all letters: Strtoupper ()
Example
The code is as follows
Copy Code
operator symbol (action symbol)
The function of the operation symbol is divided intoOne: Arithmetic operators (+-*/% + +-)%//has two purposes: integer operation, control range operation (do not use decimal, and do not use negative numbers)Turns the
We have to use Content-type:text/json to display the JSON data properly.
The code is as follows
Copy Code
Header (' Content-type:text/json '); This is the point, it tells the object receiving the data this page output is
Similar_text-calculate the similarity between two stringsInt similar_text (string $ first, string $ second [, float & $ percent])$ First is required. Specifies the first string to be compared.$ Second is required. Specifies the second string to be
The SimpleXML function allows you to convert XML into objects.This object can be processed by using a common attribute selector or array iterator, just like any other object.Some of these functions require the latest PHP version.InstallSimpleXML
1. Obtain the unix timestamp of the specified dateStrtotime ("2009-1-22") example:1. echo strtotime ("2009-1-22 ")Result: 1232553600Returns the January 22, 2009 00:00:00 timestamp.2. Obtain the date and time of the English textExample:For ease of
SyntaxStrtotime (time, now) parameter descriptionTime specifies the time string to be parsed.Now is used to calculate the timestamp of the returned value. If this parameter is omitted, the current time is used.Example The code is as follows:Copy
Let's not talk about the instance first.#1 array_unshift () example The code is as follows:Copy code $ Queue = array ("orange", "banana"); // defines an arrayArray_unshift ($ queue, "apple", "raspberry"); // Insert an element to the arrayPrint_r
The code is as follows:Copy code $ Str = "Remove leading and trailing spaces ";Echo "the original string is in square brackets: [". $ str. "] ";Echo "original string length:". strlen ($ str). " ";$ Str1 = ltrim ($ str );Echo "length after ltrim (
Php Tutorial date () date and time functionsThe php date () function can format the timestamp as a date and time with better readability.SyntaxDate (format, timestamp) parameter descriptionFormat is required. The format of the specified
$ _ Files ["file"] ["name"]-name of the uploaded file$ _ Files ["file"] ["type"]-type of the file to be uploaded$ _ Files ["file"] ["size"]-size of the uploaded file, in bytes$ _ Files ["file"] ["tmp_name"]-name of the temporary copy of the file
Php Tutorial substr_replace replacing specified location characters and memory corruption vulnerabilityTips and commentsNote: If start is a negative number and the length is less than or equal to start, the length is 0.$ Username = "zongzi ";Echo
Php Tutorial date () convert mktime () to readable dateThe date/time function allows you to extract and format the date and time on the server.The mktime () function returns the unix timestamp of a date.The parameter always represents the gmt date,
$ Fp = fopen ("test.txt", "r ");// Open the file in read-only mode and point the file pointer to the file header$ Fp = fopen ("test.txt", "r + ");// Open the file in read/write mode and point the file pointer to the file header$ Fp = fopen
SyntaxPrintf (format, arg1, arg2, arg ++) parameter descriptionFormat is required. Specifies the string and how to format the variable.Arg1 is required. Specifies the parameter inserted at the first % symbol in the formatted string.Optional.
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