我有一個(gè)由 2 個(gè)可選屬性組成的功能,以及如何發(fā)送值高?function test($size=1,$hight=2){// code .........} test($hight) test(null,$hight);還有其他方法嗎?我不需要測試(null,$ hight);
2 回答

倚天杖
TA貢獻(xiàn)1828條經(jīng)驗(yàn) 獲得超3個(gè)贊
你可以使用它,也許它會對你有所幫助。
function test($hight=null,$size=null){
// code .........
}
$hight = 2;
$size = 1;
test($hight)
test($hight,''); // if you pass as '' - blank even it's work and if second parameter is not given even it will work.

梵蒂岡之花
TA貢獻(xiàn)1900條經(jīng)驗(yàn) 獲得超5個(gè)贊
您可以嘗試將功能更改為這樣的東西嗎?
function test() {
$args = func_get_args();
/** now you can access these as $args[0], $args[1] **/
}
- 2 回答
- 0 關(guān)注
- 136 瀏覽
添加回答
舉報(bào)
0/150
提交
取消