如何使用Laravel从命名空间中查找特定字符串(How to find specific string from namespace using Laravel)
我在查找名称空间App\Models\Wordpress\Wordpress的特定字符串时遇到问题。 我想得到最后一个字符串WordPress ,有什么方法可以找到它吗?
I have a problem finding a specific string from the namespace App\Models\Wordpress\Wordpress. I want to get the last string WordPress, is there any way to find this?
最满意答案
如果你有一个动态命名空间,你可以使用魔术常量 __NAMESPACE__ :
$arr = explode("\\", __NAMESPACE__); $last = end($arr);If you have a dynamic namespace, you can use the magic constant __NAMESPACE__:
$arr = explode("\\", __NAMESPACE__); $last = end($arr);更多推荐
发布评论