参数引用 “&”
<?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!