I have a program. It accepts an input of a alphanumeric string (which I already do checks for).
So a valid input would be www.example.com/myfile.php?input=John1
However, if someone were to type in www.example.com/myfile.php?input[]
then it breaks my entire program's logic breaks because I don't accept input as an array. How can I unsure the thing a user enters is just a string. Not an array, or any other data types/structures?
There is the slow and tedious way of solving this problem, which involves a lot of manual type-checking. Expect to wear your keyboard out writing
if (!is_string($foo))
conditions throughout your application.Or you could use Ionizer which was designed for solving this exact problem.
If someone attempts to pass an array instead of a string,
$ic($_POST)
throws aTypeError
which you can then catch, log, and fail gracefully.