Home > Backend Development > PHP Tutorial > Custom desktop without IE to make PHP custom function return multiple values

Custom desktop without IE to make PHP custom function return multiple values

WBOY
Release: 2016-07-29 08:35:17
Original
948 people have browsed it

PHP custom functions only allow the return statement to return a value. When the return is executed, the entire function will terminate. Sometimes when we require a function to return multiple values, using return cannot output the values ​​one after another. But one thing that cannot be ignored is that the return statement can return any type of variable. This is the key to making the custom function return multiple values. Please see the code:
function results($string)
{
$result = array();
$result[] = $string;//Original string
$result[] = strtoupper($string );//Change all to uppercase
$result[] = strtolower($string);//Change all to lowercase
$result[] = ucwords($string);//Change the first letter of the word to uppercase
return $ result;
}
$multi_result = results('The quick brown fox jump over the lazy dog');
print_r($multi_result);
?>
Output results:
Array
(
[0] => The quick brown fox jump over the lazy dog ​​
[1] => THE QUICK BROWN FOX JUMP OVER THE LAZY DOG
[2] => the quick brown fox jump over the lazy dog ​​
[3] =& gt; The Quick Brown Fox Jump Over The Lazy Dog
)
The above code creates a $result array, then adds the value that has been processed and is waiting for output to $result as an element, and finally outputs $result. In this way, customization is achieved The purpose of a function returning multiple values.

The above introduces how to make the PHP custom function return multiple values ​​when customizing the desktop without IE, including the content of customizing the desktop without IE. I hope it will be helpful to friends who are interested in PHP tutorials.

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template