Use the ereg function to determine user permissions

Source: Internet
Author: User
Save user permissions as follows: $ permuser, author, and admin can be $ perm ., XXXX; add a permission string separated by special characters. In this example, the "," program uses the following code to determine whether a user has $ isperm permission: $ ispermuser; if (eregSyntaxHig

Save user permissions as follows:
$ Perm = user, author, admin
If you add a permission, it is available.
$ Perm. =, XXXX;
Add a permission string separated by special characters. In this example, "," is used.
You can use the following code to determine whether a user has the $ isperm permission:

$ Isperm = user;
If (ereg ("$ isperm", "$ perm") {echo"
Is a common user ";
} Else {
Echo"
Not a common user ";}

$ Isperm = author;
If (ereg ("$ isperm", "$ perm") {echo"
Is the moderator ";
} Else {
Echo"
Not the moderator ";}

$ Isperm = admin;
If (ereg ("$ isperm", "$ perm") {echo"
Is administrator ";
} Else {
Echo"
Not an administrator ";}

It must be noted that names of different permissions cannot be included, for example:
Admin and bbsadmin
We recommend that you add a special prefix or suffix to each permission name, for example:
Bbsadmin, chatadmin, webadmin
OK.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.