时间:2021-07-01 10:21:17 帮助过:23人阅读
1、变量、数组的应用技巧
(1)很多人用得不多的数组函数。foreach、list、each。分别举几个例子,应该就能知道了。例:
$data = array('a' => 'data1', 'b' => 'data2', 'c' => 'data3');
while(list($subscript, $value) = each($data)) { echo "$subscript => $value :: "; echo "$subscript => $valuen "; } reset($data); foreach($data as $subscript => $value) { echo "$subscript => $value :: "; echo "$subscript => $valuen "; } |
//变量的变量
$var = "this is a var"; $varname = "var"; echo $$varname; //函数的变量 function fun1($str) { echo $str; } $funname = "fun1"; $funname("This is a function !"); ?> |
function($a) {
$a ++; } $c = 0; function($c); echo $c; //$c仍为0 function(&$a) { $a ++; } $c = 0; echo $c; //$c为1 ?> |
http://www.bkjia.com/PHPjc/364182.htmlwww.bkjia.comtruehttp://www.bkjia.com/PHPjc/364182.htmlTechArticle很多的PHP程序员,尤其是学习还不是很久的,都不知道PHP的精华所在。Perl当年如何在商界出名?其强大的正则表达式。而PHP呢?他是一门从...