preg_replace('/[^a-zZ-Z0-9]/', NULL, $action['class'])
我在尝试修改/添加扩展的项目中有一行代码。
$controller = 'Controller' . preg_replace('/[^a-zZ-Z0-9]/', NULL, $action['class']);
但我不确定这条线的剂量是否符合我的想法: 将第一个字母大写,即将“order”变成“Order”
我尝试了一些测试,但它没有任何意义,因为它似乎删除了单词中的大写字母。
I got a line of code in the project i'm trying to modify/add extension to.
$controller = 'Controller' . preg_replace('/[^a-zZ-Z0-9]/', NULL, $action['class']);
but i'm not sure if this line dose what i think it dose:
Capitalize the first letter, i.e. turn "order" into "Order"
i tried a few tests, but it doesn't make any sense, as it seems to remove capital letters in words..
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
这将简单地删除
$action['class']
中的第一个字母数字字符。如果您想将第一个字母大写,请使用
ucfirst
:This will simply remove the first alphanumeric character in
$action['class']
.If you want to uppercase the first letter, use
ucfirst
:您可能需要使用 ucfirst()。它将把字符串的第一个字符大写。
You might want to use ucfirst(). It will capitalize the first character of a string.
这似乎没有多大意义,而且看起来像是一个错字。在目前的形式中,它用 NULL 替换除 az、Z、0-9 之外的所有内容。我想,真正的意思是这样的:
This doesn't seem to make a lot of sense and looks like a typo. In its current form, it replaces everything, that is not a-z, Z, 0-9 with NULL. I assume, what was really meant, is this: