$post is used to simulate $_POST, and I found that $_POST['int'] is a string.
How can I tell whether $post['int'] is an integer?
The following indicates that it is not an integer.
<?php
$post=array('int'=>(string)123);
var_dump($post);
echo(is_int($post['int'])?'int':'not int');
?>
EDIT. Per the documentation (http://php.net/manual/en/function.is-int.php ), is_int — Find whether the type of a variable is integer, so obviously it does exactly what it is suppose to do. Still need to tell whether the string is an integer...
$post is used to simulate $_POST, and I found that $_POST['int'] is a string.
How can I tell whether $post['int'] is an integer?
The following indicates that it is not an integer.
<?php
$post=array('int'=>(string)123);
var_dump($post);
echo(is_int($post['int'])?'int':'not int');
?>
$post is used to simulate $_POST, and I found that $_POST['int'] is a string.
How can I tell whether $post['int'] is an integer?
The following indicates that it is not an integer.
<?php
$post=array('int'=>(string)123);
var_dump($post);
echo(is_int($post['int'])?'int':'not int');
?>
EDIT. Per the documentation (http://php.net/manual/en/function.is-int.php ), is_int — Find whether the type of a variable is integer, so obviously it does exactly what it is suppose to do. Still need to tell whether the string is an integer...
testing if php string is an integer
$post is used to simulate $_POST, and I found that $_POST['int'] is a string.
How can I tell whether $post['int'] is an integer?
The following indicates that it is not an integer.
<?php
$post=array('int'=>(string)123);
var_dump($post);
echo(is_int($post['int'])?'int':'not int');
?>