kirby kirby - 1 year ago 64
PHP Question

PHP is_int is not performing as expected

I have a page (index.php) that takes a

variable from the URL and checks it for security purposes. This
variable should only be an integer. I am using the following code to check this, but in all instances, integer or not, I get the index.php page. The header never appears. After this code, the rest of the page appears starting with the


<?php ob_start(); session_start();
if (!is_numeric($q)){
header("HTTP/1.0 404 Not Found");

Answer Source

It won't be an integer if it's passed in a query string.

Try is_numeric()