source of function get_input
Can someone tell me where to find the source of the function get_input as used in:

$variable = $mybb->get_input('xxxx',1);

I wonder what the function of the 2nd argument is, and what the difference is with simply:

$variable = $mybb->input['xxxx'];

I echo'ed some results and untill now they were the same. But there will be exceptions of course, and I am curious which these are. Sometimes I see that the second argument is omitted.
Regards, Ad Bakker (NL)

This function can be found in inc/class_core.php:

This function can be used to get input in a particular form. Example:

$var = $mybb->get_input('uid', MyBB::INPUT_INT);
// $var is an integer

// Alternative without get_input:
$var = (int) $mybb->input['uid'];

Other types are:
  • MyBB::INPUT_STRING - casts to a string (the default, used if no second parameter is passed)
  • MyBB::INPUT_ARRAY - casts to an array type
  • MyBB::INPUT_INT - casts to an integer type
  • MyBB::INPUT_FLOAT - casts to a float (eg: 15.43) type
  • MyBB::INPUT_BOOL - casts to a boolean (true/false) type
Ah...., that's it. Knowing this I can proceed without problems Smile .

Thanks very much for the prompt reply!!!
Regards, Ad Bakker (NL)
No problem. We advise that you use get_input() when working with 1.8.0 or greater.

Forum Jump:

Users browsing this thread: 1 Guest(s)