Hi,
When I run the following code...
<?php
if ($_GET['view'])
{
echo 'test';
}
.. and then navigate to index.php?view=1 the above code outputs 'test', as intended.
The same goes for any non-zero value after the ?view=
However, navigating to index.php?view=0 does not work as intended because it assumes that the 0 is FALSE.
So if I modify the code, like this:
<?php
if ($_GET['view'] || $_GET['view'] == 0)
{
echo 'test';
}
... it outputs 'test' even when view is not set, i.e. when I navigate to index.php without the ?view=.
Is there an easy way to force the value to behave as an integer instead of boolean? I have tried putting (int) before, as well as the intval() function, but neither seem to work.
Thanks.