note 34804 deleted from function.is-numeric by crell

From: Date: Mon, 18 Apr 2022 14:56:30 +0000
Subject: note 34804 deleted from function.is-numeric by crell
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-218276@lists.php.net to get a copy of this message
Note Submitter: stew_wilde at hotmail dot com ---- When using the exec() function in php to execute anther php script, any command line arguments passed the script will lose their type association, regardless of whether they are numeric or not, the same seems to hold true for strings as well. ie : two scripts test.php: <?php $val = trim($argv[1]); echo is_string($val); ?> and testwrapper.php: <?php $tmp = 5; exec("php ./test.php ".$tmp); ?> Executing testwrapper.php on the command line will echo nothing (ie false), and false will be returned regardless of any escaping of parameters or other such attempts to overcome this. The solution then is to explicitly cast $val in test.php to be an int and then is_numeric will work. But as stated the same test was performed using a string for $val and the is_string() function and the same thing occurs. Not the end of the world, but something to be aware of :)

« previous php.notes (#218276) next »