PHP Programing language

How can Using Optional Parameter
Previous Home Next
<html>
<head>
<title>Using Optional Parameter</title>
</head>
<body>
<h1>Using Optional Parameter</h1>
<?php
$a = array('A', 'B', 'C', 'D', 'E');
$admin = array('F', 'G');

function check_access($username, $adminonly = false) 
{
    global $a, $admin;

    if (in_array($username, $admin)) 
	{
        return true;
    }

    if (!($adminonly) && in_array($username, $a)) 
	{
        return true;
    }

    return false;
}

echo check_access('r') ? 'is' : 'is NOT' ,"
allowed.</p>";
echo check_access('q') ? 'is' : 'is NOT' ,"
allowed.</p>";

echo check_access('r', true) ? 'is' : 'is NOT'
," an admin.</p>";
echo check_access('q', true) ? 'is' : 'is NOT'
," an admin.</p>";
?>  
</body>
</html>

 

Output:

Previous Home Next

Tolal:0 Click:

Show All Comments

Did not find what you were looking for leave your name and message. We will revert within 24 hours
Name:
eMail:
Comment / Feedback: