【发布时间】:2015-01-26 06:08:33
【问题描述】:
我正在用 PHP 构建一个用户模块。它读取基于文本的用户类型并分配一个数值来管理报表查看权限:
if ($usr_type == "Architect"){ $usr_rights = 0; }
if ($usr_type == "Director"){ $usr_rights = 1; }
if ($usr_type == "Manager"){ $usr_rights = 2; }
if ($usr_type == "Associate"){ $usr_rights = 3; }
if ($usr_type == "Assistant"){ $usr_rights = 4; }
if ($usr_type == "External"){ $usr_rights = 5; }
有没有更简单、更优雅的方法来做到这一点?
【问题讨论】:
-
仅供参考:如果您还没有看过它,您可以在这里参观:stackoverflow.com/tour 并了解该网站的运作方式!
标签: php if-statement