zend-framework 中第三种添加角色的不同之处

发布于 2024-12-26 07:18:35 字数 258 浏览 2 评论 0原文

在zend框架中我们可以添加三种类型的acl我想知道它们之间有什么不同

$acl = new Zend_Acl();
// 1st type
$acl -> addRole(new Zend_Acl_Role('someuser'));
// 2nd type
$acl -> add (new Zend_Acl_Role('someuser'));
// 3rd type
$acl -> addRole('someuser');

in zend frame work we can add acl in three type I want to know what is different between them

$acl = new Zend_Acl();
// 1st type
$acl -> addRole(new Zend_Acl_Role('someuser'));
// 2nd type
$acl -> add (new Zend_Acl_Role('someuser'));
// 3rd type
$acl -> addRole('someuser');

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

忱杏 2025-01-02 07:18:35

第一个和第三个完全一样。根本没有区别。
addRole 函数中会发生以下情况:

if (is_string($role)) {
    $role = new Zend_Acl_Role($role);
}

由于 $role 是给定参数,因此两者相同。

第二种类型已被弃用(并用于资源),因此应避免使用它。

The first and third are exactly the same. There simply is no difference.
The following happens in the addRole function:

if (is_string($role)) {
    $role = new Zend_Acl_Role($role);
}

Since $role is the given parameter the two are the same.

The second type is deprecated (and used for resources) so using it should be avoided.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文