note 116994 deleted from function.strpos by cmb

From: Date: Sun, 02 Jun 2019 08:01:31 +0000
Subject: note 116994 deleted from function.strpos by cmb
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-211165@lists.php.net to get a copy of this message
Note Submitter: newartix at mail dot ru ---- Extend (ohcc at 163 dot com)s comment: Be careful when the $haystack or $needle parameter is an integer. If you are not sure of its type, you should convert it into a string. <?php var_dump(strpos(12345,1));//false var_dump(strpos(12345,'1'));//0 var_dump(strpos('12345',1));//false var_dump(strpos('12345','1'));//0 $a = 12345; $b = 1; var_dump(strpos(strval($a),strval($b)));//0 var_dump(strpos((string)$a,(string)$b));//0 // and wait for interesting... CentOS 6.5 PHP-FPM 5.4.35 var_dump(strpos('mrwagon',626));//1 tadaaam! ?>

« previous php.notes (#211165) next »