无法使用自定义函数格式化 PHP 中的字符串
<?php
$string = 'tHis is aN unEVen string that needs to be formated properly';
// custom function created combining multiple functions
function varform($var){
ucwords(strtolower(htlmentities(trim($var))));
return $var;
}
$string = varform($string);
echo $string;
?>
<?php
$string = 'tHis is aN unEVen string that needs to be formated properly';
// custom function created combining multiple functions
function varform($var){
ucwords(strtolower(htlmentities(trim($var))));
return $var;
}
$string = varform($string);
echo $string;
?>
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
您需要将所有操作的结果分配给您要返回的变量
You need to assign the result of all your manipulations to the variable you are about to return
您的代码有两个问题
您需要从 PHP 方法获取返回值并从函数返回该值
There are two problems with your code
You need to get the return value from the PHP methods and return that from your function
1)用htmlentities替换htlmentities
,正如之前的评论者所说
1) replace htlmentities by htmlentities
and as the previous commenters said