返回值_PHP

WBOY
Release: 2016-06-01 12:39:44
Original
744 people have browsed it

使用一些可选的返回语句,任何类型的数值都能被返回,包括对象和广义表.

function my_sqrt ($num)

{

return $num * $num;

}

echo my_sqrt (4); // 输出 '16'.

 

可以返回多值,但是同时的影响使通过一个广义表来实现:

function foo()

{

return array (0, 1, 2);

}

list ($zero, $one, $two) = foo();

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
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!