note 29488 modified in function.strstr by danbrown

From: Date: Fri, 28 Nov 2008 20:05:46 +0000
Subject: note 29488 modified in function.strstr by danbrown
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-147176@lists.php.net to get a copy of this message
PHP versions before 4.3.0 (tested on 4.2.2 and 4.2.3) return the $haystack from $needle only up to the first null character. So for example: <?php $string = strstr("one#two\x00three", "#"); // PHP 4.2.x: $string contains "#two" // PHP 4.3.0: $string contains "#two\x00three" ?> If you're trying to match nulls, you will probably get back an empty string: <?php $string = strstr("one#two\x00three", "\x00"); // PHP 4.2.x: $string contains "" // PHP 4.3.0: $string contains "\x00three" ?> --was-- PHP versions before 4.3.0 (tested on 4.2.2 and 4.2.3) return the $haystack from $needle only up to the first null character. So for example: $string = strstr("one#two\x00three", "#"); // PHP 4.2.x: $string contains "#two" // PHP 4.3.0: $string contains "#two\x00three" If you're trying to match nulls, you will probably get back an empty string: $string = strstr("one#two\x00three", "\x00"); // PHP 4.2.x: $string contains "" // PHP 4.3.0: $string contains "\x00three" http://php.net/manual/en/function.strstr.php

« previous php.notes (#147176) next »