關(guān)于返回值的問題
function numbers() { ? ?return array(1, 2, 3); } list ($one, $two, $three) = numbers(); 這個(gè)是什么意思?怎么呢才可以打印出來?
function numbers() { ? ?return array(1, 2, 3); } list ($one, $two, $three) = numbers(); 這個(gè)是什么意思?怎么呢才可以打印出來?
2016-03-24
舉報(bào)
2016-03-24
函數(shù)numbers() 返回一個(gè)數(shù)組 array(1,2,3)
而list() 函數(shù)用于在一次操作中給一組變量賦值。
該函數(shù)只用于數(shù)字索引的數(shù)組,且假定數(shù)字索引從 0 開始。
所以
?list ($one, $two, $three) = numbers(); 這個(gè)的意思就是將
函數(shù)numbers()的返回值賦值給變量$one $two $three?
要打印出來 就用echo 就行
2016-03-24
list ($one, $two, $three) = numbers();是將函數(shù)返回的數(shù)組中的三個(gè)值,分別賦予$one, $two, $three;
在最下面使用以下語句,可以進(jìn)行打印輸出
echo "$one, $two, $three";