2012-02-10 8 views
2

別の関数に戻りますそれはmyfunction2(myfunction)のように見えるだろうと推測しますが、私はあまりPHPを知らないし、それを動作させることができませんでした。PHP渡す機能は、私が何かを返すPHPの機能を持っている

+2

を例作業onetwothreefoursomthing else

を返します

function myfunction() { $array = array('one', 'two', 'three', 'four'); $concat = ''; foreach($array as $i) { $concat .= $i; } return $concat; } function myfunction2() { return myfunction() . "something else"; } 

を右音does'nt。一度戻って関数を終了するので、次の配列項目には到達しません。 – Orhan

+0

私はあなたの質問を正確に理解していません。あなたはもっと明確になりますか? – DonCallisto

+0

私のせいで、私は "エコー"を意味しました! – Wordpressor

答えて

5

はい、あなただけ常に"one"を返します

return myFunction(); 
0

myfunctionを必要としています。他に何もない。 return

その後、ある関数の戻り値を別の関数の中に残したい場合は、それを呼び出してください。

function myfunction2() { 
    $val = myfunction(); 
    return "something else"; 
} 
0
function myfunction2() { 

    $myvariable=myfunction(); 
    //$myvar now has the output of myfunction() 

    //You might want to do something else here 

return 'something additional'; 
} 
関連する問題