You know, the future, this is your tool.
- If the code can make money, the most money to help you is the basic grammar
- If you're still a programmer, your best friend is the handbook.
问问你自己:你有CSS2.0/3.0手册,JavaScript手册,Jquery手册,HTML手册吗?
So how do you check out manuals and study manuals?
- Understand the function of functions, especially functions of common functions
- Understanding the parameters of a function
- Understanding the return value of a function
Know the rules.
Explains 6 functions, 6 functions, and outlines all the considerations for basic usage of functions:
- Returns the Boolean type directly, such as bool copy ()
- How the function with the mixed parameter is called. Mixed represents any type of data. such as Array_unshift ()
- Parameters with the & character, be sure to pass a variable as a parameter. The function inside changed his value.
- A parameter with [], which indicates an optional option.
- With... parameter, which means that any number of arguments can be passed.
- A parameter with callback that represents the callback function. A function needs to be passed in. Array_map ()
Supported versions of the function you need to understand
Code experiment
1. Take copy () as an example: Returns the bool value, usually whether the operation is successful, whether the validation is passed, whether the check is correct, and so on.
The copy function looks at:
BOOL Copy (string souRCe,sTRINg s o u r c e , s t r i n g dest [, Resource $context])
function : Copy a file
return value : BOOL value, which is the successful return true, the failure returns false
parameters : Two string value, one copy of the source file, and one for the target file. The third parameter is optional, not commonly used, and we don't care about it.
<?php
if(copy(‘abc.txt‘,‘bcd.txt‘)){
echo ‘复制成功‘;
}else{
echo ‘复制失败‘;
}
?>
2.Mixed represents any type of data. such as Array_unshift ()
int Array_unshift (Array & aRRay ,mIxed a R r a y , m i x e d Value1 [, Mixed $ ...])
function : Manipulate an array to insert other types of parameters before the array.
return value : type int, possibly the last number of successful inserts
Parameters :
- The first argument is the & character, which is the value of the first parameter that was changed during the operation. Reference to the parameter. That is, manipulate the array and pass in the arguments to the array. Will change the value of this array directly.
- The second argument is mixed, because the array can be stored in several different types. Mixed refers to the meaning of mixing. Therefore, mixed refers to any type that can be passed in
- The third number is added in brackets, and we all encounter the brackets. refers to the following parameters can be passed, or do not pass.
- Four, finally saw three ... (ellipsis). A delegate can pass in any number of arguments.
<?php
$queue = array("凤姐", "芙蓉");
array_unshift($queue, "杨幂", "姚晨");
print_r($queue);
?>
3. Encounter callback function or anonymous function to assist in processing, make the function more powerful.
BOOL Array_walk (Array & aRRay ,CaLLabLe a R r a y , c a l l a b l E callback [, Mixed $userdata = NULL])
function : A callback function is passed in, and the array's original group is manipulated and changed.
return value : bool value, which means that the prompt succeeds or fails
Parameters :
- The first parameter is the array to manipulate.
- The second argument is that callback represents the ability to pass in functions or anonymous functions.
<?php
$shuaige = array("a" => "wuyanzhu", "b" => "huangxiaoming", "c" => "ninzetao");
function test_print($item2, $key)
{
echo $key ." ---". strtoupper($item2) . "<br />\n";
}
echo ‘<pre>‘;
var_dump($shuaige);
echo ‘</pre>‘;
array_walk($shuaige, ‘test_print‘);
echo ‘用自定义函数test_print执行后的效果:‘;
echo ‘<pre>‘;
var_dump($shuaige);
echo ‘</pre>‘;
?>
4. Check the version number of the function in the manual
!
From for notes (Wiz)
Front-end PHP entry -017-system built-in functions-check API