Default acceptable parameter set in PHP function

Asked

Viewed 62 times

0

In the example:

public function getEstoqueDeposito($busca, $deposito = FALSE) {
    ...
}

I know what I could do:

public function getEstoqueDeposito($busca, $deposito = FALSE) {
    if($busca == 'TOTAL'){
        ...
        return "whatever";
    } else if($busca == 'GRUPO'){
        ...
        return "whatever";
    } 
    return "Parâmetro inválido";
}

Anyway, I would like to preset the values (TOTAL or GROUP) in the $search parameter, in PHP, have some way to do this without the need to do a test within the function?

  • 1

    I don’t think I understand, you’ve done it in $deposit, just do the same in search $search = 'TOTAL'

  • Hello Anderson, it is not preset if the parameter is not passed, in fact I need the function to only accept TOTAL or GROUP in the $search parameter.

  • 2

    http://php.net/manual/en/class.splenum.php

No answers

Browser other questions tagged

You are not signed in. Login or sign up in order to post.