source of function get_input
#1
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)
Reply
#2
Hi,

This function can be found in inc/class_core.php: https://github.com/mybb/mybb/blob/featur...e.php#L443

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
Reply
#3
Ah...., that's it. Knowing this I can proceed without problems Smile .

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


Forum Jump:


Users browsing this thread: 1 Guest(s)