php從字符串創(chuàng)建函數(shù)的方法
本文實(shí)例講述了php從字符串創(chuàng)建函數(shù)的方法。分享給大家供大家參考。具體如下:
php中可以把整個(gè)函數(shù)定義放到一個(gè)字符串內(nèi)動(dòng)態(tài)定義,有了create_function這個(gè)函數(shù),你就可以根據(jù)用戶輸入動(dòng)態(tài)創(chuàng)建函數(shù)了,非常方便,create_function使用方法如范例所示:
$lambda =create_function('$a,$b','return(strlen($a)-strlen($b));');
$array = array('really long string here,boy', 'this', 'middling length','larger');
usort($array,$lambda);
print_r($array);
?>
希望本文所述對(duì)大家的php程序設(shè)計(jì)有所幫助。
相關(guān)文章
使用PHP連接多種數(shù)據(jù)庫(kù)的實(shí)現(xiàn)代碼(mysql,access,sqlserver,Oracle)
我們今天為大家介紹的PHP連接數(shù)據(jù)庫(kù)的方法包括在MYSQL數(shù)據(jù)庫(kù)、ACCESS數(shù)據(jù)庫(kù)、MS SQL數(shù)據(jù)庫(kù)和Oracle數(shù)據(jù)庫(kù)中實(shí)現(xiàn)2016-12-12
PHP錯(cuò)誤Parse error: syntax error, unexpected end of file in te
這篇文章主要介紹了PHP錯(cuò)誤Parse error: syntax error, unexpected end of file in test.php on line 12解決方法,需要的朋友可以參考下2014-06-06

