Front-end PHP entry -017-system built-in functions-check API

Source: Internet
Author: User

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?

    1. Understand the function of functions, especially functions of common functions
    2. Understanding the parameters of a function
    3. 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:

    1. Returns the Boolean type directly, such as bool copy ()
    2. How the function with the mixed parameter is called. Mixed represents any type of data. such as Array_unshift ()
    3. Parameters with the & character, be sure to pass a variable as a parameter. The function inside changed his value.
    4. A parameter with [], which indicates an optional option.
    5. With... parameter, which means that any number of arguments can be passed.
    6. 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.

  
 
  1. <?php
  2. if(copy(‘abc.txt‘,‘bcd.txt‘)){
  3. echo ‘复制成功‘;
  4. }else{
  5. echo ‘复制失败‘;
  6. }
  7. ?>

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.
  
 
  1. <?php
  2. $queue = array("凤姐", "芙蓉");
  3. array_unshift($queue, "杨幂", "姚晨");
  4. print_r($queue);
  5. ?>

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.
  
 
  1. <?php
  2. $shuaige = array("a" => "wuyanzhu", "b" => "huangxiaoming", "c" => "ninzetao");
  3. function test_print($item2, $key)
  4. {
  5. echo $key ." ---". strtoupper($item2) . "<br />\n";
  6. }
  7. echo ‘<pre>‘;
  8. var_dump($shuaige);
  9. echo ‘</pre>‘;
  10. array_walk($shuaige, ‘test_print‘);
  11. echo ‘用自定义函数test_print执行后的效果:‘;
  12. echo ‘<pre>‘;
  13. var_dump($shuaige);
  14. echo ‘</pre>‘;
  15. ?>

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

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.