Home >Backend Development >PHP Tutorial >Use the ereg function to determine user permissions_PHP tutorial

Use the ereg function to determine user permissions_PHP tutorial

WBOY
WBOYOriginal
2016-07-13 17:25:03890browse

Save user permissions in the following format:
$perm=user,author,admin
If you want to add permissions, you can use
$perm.=,XXXX;
to add permission strings, with special characters in between Characters are separated. This example uses ","
When you need to determine whether the user has $isperm permissions in the program, you can use the following code:

$isperm=user;
if(ereg("$ isperm", "$perm")){echo "
is an ordinary user";
}else{
echo "
is not an ordinary user"; }

$isperm=author ;
if(ereg("$isperm", "$perm")){echo "
is a moderator";
}else{
echo "
is not a moderator"; }

$isperm=admin;
if(ereg("$isperm", "$perm")){echo "
is the administrator";
}else{
echo "
Not an administrator";}

It must be pointed out that the names of different permissions cannot be inclusive of each other, such as:
admin and bbsadmin
It is recommended that each permission name be added with a unique prefix or Suffixes, such as:
bbsadmin, chatadmin, webadmin
are OK.

www.bkjia.comtruehttp: //www.bkjia.com/PHPjc/532077.htmlTechArticleSave user permissions in the following format $perm=user,author,admin If you add permissions, you can use $ perm.=,XXXX; Add permission string, separated by special characters. In this example, "," is used...
Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn