+ 2

What's the statement or function to take input from user in php in any specific data type

console input

24th Nov 2018, 5:43 PM
Preeti
Preeti - avatar
3 Answers
+ 2
There are type hints in php5+ where we can define a data type for function parameters. Or you can use instaceof, is_numeric, is_array, etc
24th Nov 2018, 6:19 PM
Taste
Taste - avatar
+ 1
Taste can u please give a code to show it
24th Nov 2018, 6:32 PM
Preeti
Preeti - avatar
+ 1
Simply function(boolean $b){ //error if the passed parameter is not boolean } And here, where you can see all the available type and how to use them http://php.net/manual/en/functions.arguments.php#functions.arguments.type-declaration
24th Nov 2018, 6:36 PM
Taste
Taste - avatar