如何在PHP函数中使用另外一个函数返回的数组
示例代码如下,最后在f2中得不到f1返回的数组,print_r($b);显示为空
<!--
Code highlighting produced by Actipro CodeHighlighter (freeware)
http://www.CodeHighlighter.com/
-->
<?PHP
function f1()
{
$a=array("1","2","3"); /* 定义一个数组 */
return $a;
}
function f2()
{
$b = f1();
print_r($b);
}
f2();
?>
<a style="color:#f60; text-decoration:underline;" title="php" href="https://www.php.cn/zt/15714.html" target="_blank">php</a>
function f1()
{
$a=array("1","2","3"); /* 定义一个数组 */
return $a;
}
function f2()
{
$b = f1(); #如果在类中,就需要$this->f1()
print_r($b);
}
f2();
#Array ( [0] => 1 [1] => 2 [2] => 3 )
?>
<br><font color="#e78608">------解决方案--------------------</font><br>没有关系<br>都能得到结果
<br><font color="#e78608">------解决方案--------------------</font><br>反正我的是能得到 <div class="clear"></div>
PHP怎么学习?PHP怎么入门?PHP在哪学?PHP怎么学才快?不用担心,这里为大家提供了PHP速学教程(入门到精通),有需要的小伙伴保存下载就能学习啦!
Copyright 2014-2025 https://www.php.cn/ All Rights Reserved | php.cn | 湘ICP备2023035733号