如何使用Laravel从命名空间中查找特定字符串(How to find specific string from namespace using Laravel)

编程入门 行业动态 更新时间:2024-10-27 00:22:39
如何使用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);

更多推荐

本文发布于:2023-08-04 15:50:00,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1418944.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:字符串   如何使用   空间   Laravel   namespace

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!