davice

  博客园  :: 首页  :: 新随笔  :: 联系 :: 订阅 订阅  :: 管理

参数引用 “&”

 

<?php
function capitalize(&$str,$each=TRUE)
{
    $str = strtolower($str);
    if ($each === true){
    
     $str = ucwords($str);
    }else{
        $str{0} =strtoupper($str{0});
    }
}
$str = "hEllo World!";
capitalize($str);
echo $str;

?>

 

输入结果:

Hello World!

 

如果不加  &    输入结果:hEllo World!

posted on 2011-11-22 09:21  davice  阅读(820)  评论(0编辑  收藏  举报