php 如何得到函數的參數名_PHP教程

來源:互聯網
上載者:User
問題
如何得到函數的參數名?
解決方案
$test = 'this is a test';

$abc = 'aaaaaaaaa';

getit($test);



function getit($l){

// 此處獲得 $l 的名稱 而不是值

// 當$test 做參數輸入時, 顯示 '$test' 這個字串, 而不是 $test 的值

// 當$abc 做參數輸入時, 顯示 '$abc' 這個字串, 而不是 $abc 的值



}


複製代碼[ ]


參考答案
這。。這有用嗎?

好像不能得到。

除非你把檔案讀取過來,用正則匹配。
參考答案
原帖由 wbsifan 於 2009-1-4 10:46 發表 [url=http://bbs.111cn.cn/redirect.php?goto=findpost&pid=814417&ptid=100342]連結標記[img]http://bbs.111cn.cn/images/common/back.gif[/img][/url]

$test = 'this is a test';
$abc = 'aaaaaaaaa';
getit($test);

function getit($l){
// 此處獲得 $l 的名稱 而不是值
// 當$test 做參數輸入時, 顯示 '$test' 這個字串, 而不是 $test 的值
// 當$abc ...
照你這種應用?
getit('aaa');
應該顯示什麼? [img]http://www.111cn.cn/bbs/images/smilies/default/03.gif[/img]
參考答案
意義。[img]http://www.111cn.cn/bbs/images/smilies/default/lol.gif[/img]
參考答案
這個先別考慮了...
幫我想想如何得到參數名...
參考答案
學習中
參考答案
不太明白你的意思,c++裡面有一個引用傳值,指標傳值,可能會對你有用
參考答案




function test($val) {



if (is_array($val)){



foreach($val as $value){



$arr[]=$value;



}

return $arr;



}else {



$val = &$val;

return $val;



}



}

$val = 1;

var_dump(test($val));



echo "
";



$arr = array(1,2,3);

print_r(test($arr));





?>


複製代碼
參考答案
明白你的意思 但是不知道怎麼實現 以前沒想過 學習·~··
參考答案
int(1)
Array ( [0] => 1 [1] => 2 [2] => 3 )

要獲得 '$arr' 這個字串.. 即參數名 而不是參數值..

http://www.bkjia.com/PHPjc/632603.htmlwww.bkjia.comtruehttp://www.bkjia.com/PHPjc/632603.htmlTechArticle問題 如何得到函數的參數名? 解決方案 $test = 'this is a test'; $abc = 'aaaaaaaaa'; getit($test); function getit($l){ // 此處獲得 $l 的名稱 而不是值 // 當...

  • 聯繫我們

    該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

    如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

    A Free Trial That Lets You Build Big!

    Start building with 50+ products and up to 12 months usage for Elastic Compute Service

    • Sales Support

      1 on 1 presale consultation

    • After-Sales Support

      24/7 Technical Support 6 Free Tickets per Quarter Faster Response

    • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.