Welcome Guest, Not a member yet? Register   Sign In
How to catch missed argumets situation?
#1

[eluser]griser[/eluser]
I have a controller with 2 argument $id and $type

function main($id,$type)
{

}

If a user misses argument for controller's function (casually or with malicious intentions) he gets error message or misformated page.

How to catch such error and process them?
#2

[eluser]pistolPete[/eluser]
You can use default values:

Code:
function main($id = 0,$type = FALSE)
{
    if($id == 0 || $type === FALSE)
    {
        // at least one argument is missing
    }
}
#3

[eluser]griser[/eluser]
[quote author="pistolPete" date="1255530912"]You can use default values:

Code:
function main($id = 0,$type = FALSE)
{
    if($id == 0 || $type === FALSE)
    {
        // at least one argument is missing
    }
}
[/quote]


Great! That will do. Thanks a lot.




Theme © iAndrew 2016 - Forum software by © MyBB