PHP - 传递函数返回到另一个函数 [英] PHP - passing functions return to another function

查看:101
本文介绍了PHP - 传递函数返回到另一个函数的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

  function myfunction(){
$ array = array( '一二三四');

foreach($ array as $ i){
echo $ i;






$ b

另外一个函数,我想传递返回值上面的函数:

  function myfunction2(){
//如何在这里发送myfunction()的输出?我的意思是:
// echo'onetwothreefour';
返回额外的东西;
}

我想它会看起来像 myfunction2(myfunction )但我不知道PHP太多,我无法完成工作。

解决方案

是的,你只需要

  return myFunction(); 


I have a PHP function that returns something:

function myfunction() {
   $array = array('one', 'two', 'three', 'four');

   foreach($array as $i) {
     echo $i;
   }
}

And another function where I want to pass return values from the function above:

function myfunction2() {
   //how to send myfunction()'s output here? I mean:
   //echo 'onetwothreefour';
   return 'something additional';
}

I guess it will look something like myfunction2(myfunction) but I don't know PHP too much and I couldn't make it work.

解决方案

Yes, you just need

return myFunction();

这篇关于PHP - 传递函数返回到另一个函数的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆