Php类(我想) [英] Php classes (I think)
本文介绍了Php类(我想)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
有没有办法创建一个简化这个
Is there a way to create a php class (or function) that "simplifies" this
ucfirst(str_replace('_',' ',html_entity_decode(trim($variable), ENT_QUOTES))));
$变量可以从任何地方来,例如从另一个函数的全局变量或只是一个标准变量
The $variable could "come" from anywhere e.g a global from another function or just a "standard" variable
推荐答案
如果你不止一次使用它,那么我肯定会把它放入一个函数。
If you are using it more than once, then I would definitely put it into a function. That way you won't be repeating all the code.
function functionName($input){
return ucfirst(str_replace('_',' ',html_entity_decode(trim($input), ENT_QUOTES)));
}
echo functionName($variable);
这篇关于Php类(我想)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文