PHP php_sapi_name () and Array_map ()

Source: Internet
Author: User

1,php_sapi_name ()

Php_sapi_name returns the interface type between the Web server and PHP. Function Description:

String Php_sapi_name (void)

Returns a lowercase string that describes the type of interface used by PHP, such as the CLI PHP under which the string is "CLI", under which Apache may have several different values depending on the SAPI used.

Instance:

<?php$sapi_type = Php_sapi_name (); if (substr ($sapi _type, 0, 3) = = ' cgi ') {    echo "you are using CGI php\n";} else { C1/>echo "You were not using CGI php\n";}? >

2,array_map ()

The Array_map () function functions The user-defined function to each value in the array and returns a new array after the action. The number of arguments that the callback function accepts should be the same as the number of arrays passed to the Array_map () function.

Grammar:

Array_map (Myfunction,array1,array2,array3 ...)

MyFunction, required, name of user-defined function, or null;array1, required, specified array, array2, array3, optional, specified array.

Instance:

<?phpfunction MyFunction ($v) {if ($v = = = "Dog")  {  return "Fido";  } return $v;} $a =array ("Horse", "Dog", "Cat");p Rint_r (Array_map ("MyFunction", $a)); >

  

PHP php_sapi_name () and Array_map ()

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.