[php-src] master: ext/standard: Deprecate passing integers outside the interval [0, 255] to chr() (#19441)

From: Date: Thu, 14 Aug 2025 19:48:51 +0000
Subject: [php-src] master: ext/standard: Deprecate passing integers outside the interval [0, 255] to chr() (#19441)
Groups: php.cvs 
Request: Send a blank email to [email protected] to get a copy of this message
Author: Gina Peter Banyard (Girgias)
Committer: GitHub (web-flow)
Pusher: Girgias
Date: 2025-08-14T20:48:48+01:00

Commit: https://github.com/php/php-src/commit/cab46b27b9d0a91c30b596a9e1838ba1e353359c
Raw diff: https://github.com/php/php-src/commit/cab46b27b9d0a91c30b596a9e1838ba1e353359c.diff

ext/standard: Deprecate passing integers outside the interval [0, 255] to chr() (#19441)

RFC: https://wiki.php.net/rfc/deprecations_php_8_5#deprecate_passing_integers_outside_the_interval_0_255_to_chr

Changed paths:
  A  ext/standard/tests/strings/chr_out_of_range.phpt
  M  Zend/zend_compile.c
  M  ext/gd/tests/gh16232.phpt
  M  ext/standard/string.c
  M  ext/standard/tests/array/array_filter_variation9.phpt
  M  ext/standard/tests/strings/chr_variation1.phpt
  M  ext/standard/tests/strings/str_replace_variation2.phpt
  M  ext/standard/tests/strings/strcasecmp.phpt
  M  ext/standard/tests/strings/strcmp.phpt
  M  ext/standard/tests/strings/strlen.phpt
  M  ext/standard/tests/strings/strncasecmp_variation6.phpt
  M  ext/standard/tests/strings/strpos_variation1.phpt
  M  ext/standard/tests/strings/strstr_variation1.phpt
  M  ext/standard/tests/strings/substr_count_variation_001.phpt
  M  ext/standard/tests/strings/substr_count_variation_002.phpt


Diff:

diff --git a/Zend/zend_compile.c b/Zend/zend_compile.c
index aba735124a0a5..7f4299ff9a815 100644
--- a/Zend/zend_compile.c
+++ b/Zend/zend_compile.c
@@ -4147,17 +4147,19 @@ static zend_result zend_compile_func_defined(znode *result, zend_ast_list
*args)
 }
 /* }}} */
 
-static zend_result zend_compile_func_chr(znode *result, zend_ast_list *args) /* {{{ */
+static zend_result zend_compile_func_chr(znode *result, const zend_ast_list *args) /* {{{ */
 {
-
-	if (args->children == 1 &&
-	    args->child[0]->kind == ZEND_AST_ZVAL &&
-	    Z_TYPE_P(zend_ast_get_zval(args->child[0])) == IS_LONG) {
-
-		zend_long c = Z_LVAL_P(zend_ast_get_zval(args->child[0])) & 0xff;
-
+	zval *zint;
+	if (
+		args->children == 1
+		&& args->child[0]->kind == ZEND_AST_ZVAL
+		&& (zint = zend_ast_get_zval(args->child[0]))
+		&& Z_TYPE_P(zint) == IS_LONG
+		&& Z_LVAL_P(zint) >= 0
+		&& Z_LVAL_P(zint) <= 255
+	) {
 		result->op_type = IS_CONST;
-		ZVAL_CHAR(&result->u.constant, c);
+		ZVAL_CHAR(&result->u.constant, Z_LVAL_P(zint));
 		return SUCCESS;
 	} else {
 		return FAILURE;
diff --git a/ext/gd/tests/gh16232.phpt b/ext/gd/tests/gh16232.phpt
index 7f839d737bb5b..469ae633c5da2 100644
--- a/ext/gd/tests/gh16232.phpt
+++ b/ext/gd/tests/gh16232.phpt
@@ -9,10 +9,10 @@ $bad_webp = __DIR__ . "/gh16232.webp";
 copy($good_webp, $bad_webp);
 var_dump(imagecreatefromwbmp($bad_webp));
 $data = file_get_contents($bad_webp);
-$data[3] = chr(-1);
+$data[3] = chr(255);
 file_put_contents($bad_webp, $data);
 var_dump(imagecreatefromwbmp($bad_webp));
-$data[3] = chr(1000);
+$data[3] = chr(232);
 file_put_contents($bad_webp, $data);
 var_dump(imagecreatefromwbmp($bad_webp));
 unlink($bad_webp);
diff --git a/ext/standard/string.c b/ext/standard/string.c
index 4bc56f550fe1b..a5acb28ddb3bc 100644
--- a/ext/standard/string.c
+++ b/ext/standard/string.c
@@ -2665,6 +2665,12 @@ PHP_FUNCTION(chr)
 		Z_PARAM_LONG(c)
 	ZEND_PARSE_PARAMETERS_END();
 
+	if (UNEXPECTED(c < 0 || c > 255)) {
+		php_error_docref(NULL, E_DEPRECATED,
+			"Providing a value not in-between 0 and 255 is deprecated,"
+			" this is because a byte value must be in the [0, 255] interval."
+			" The value used will be constrained using %% 256");
+	}
 	c &= 0xff;
 	RETURN_CHAR(c);
 }
diff --git a/ext/standard/tests/array/array_filter_variation9.phpt
b/ext/standard/tests/array/array_filter_variation9.phpt
index ff0dc7711718b..2e6efc0eda5d9 100644
--- a/ext/standard/tests/array/array_filter_variation9.phpt
+++ b/ext/standard/tests/array/array_filter_variation9.phpt
@@ -8,7 +8,7 @@ Test array_filter() function : usage variations - built-in functions as
'callbac
 
 echo "*** Testing array_filter() : usage variations - built-in functions as
'callback' argument ***\n";
 
-$input = array(0, 1, -1, 10, 100, 1000);
+$input = array(0, 1, 10, 100);
 
 // using built-in function 'is_int' as 'callback'
 var_dump( array_filter($input, 'is_int') );
@@ -34,33 +34,25 @@ echo "Done"
 ?>
 --EXPECT--
 *** Testing array_filter() : usage variations - built-in functions as 'callback' argument
***
-array(6) {
+array(4) {
   [0]=>
   int(0)
   [1]=>
   int(1)
   [2]=>
-  int(-1)
-  [3]=>
   int(10)
-  [4]=>
+  [3]=>
   int(100)
-  [5]=>
-  int(1000)
 }
-array(6) {
+array(4) {
   [0]=>
   int(0)
   [1]=>
   int(1)
   [2]=>
-  int(-1)
-  [3]=>
   int(10)
-  [4]=>
+  [3]=>
   int(100)
-  [5]=>
-  int(1000)
 }
 array_filter(): Argument #2 ($callback) must be a valid callback or null, function "echo"
not found or invalid function name
 array_filter(): Argument #2 ($callback) must be a valid callback or null, function
"isset" not found or invalid function name
diff --git a/ext/standard/tests/strings/chr_out_of_range.phpt
b/ext/standard/tests/strings/chr_out_of_range.phpt
new file mode 100644
index 0000000000000..8381850e80654
--- /dev/null
+++ b/ext/standard/tests/strings/chr_out_of_range.phpt
@@ -0,0 +1,15 @@
+--TEST--
+chr() with out of range values
+--FILE--
+<?php
+
+var_dump("\xFF" == chr(-1));
+var_dump("\0" == chr(256));
+
+?>
+--EXPECTF--
+Deprecated: chr(): Providing a value not in-between 0 and 255 is deprecated, this is because a byte
value must be in the [0, 255] interval. The value used will be constrained using % 256 in %s on line
3
+bool(true)
+
+Deprecated: chr(): Providing a value not in-between 0 and 255 is deprecated, this is because a byte
value must be in the [0, 255] interval. The value used will be constrained using % 256 in %s on line
4
+bool(true)
diff --git a/ext/standard/tests/strings/chr_variation1.phpt
b/ext/standard/tests/strings/chr_variation1.phpt
index f045fdb54a005..d181e752c2aad 100644
--- a/ext/standard/tests/strings/chr_variation1.phpt
+++ b/ext/standard/tests/strings/chr_variation1.phpt
@@ -5,36 +5,17 @@ Test chr() function : usage variations - test values for $ascii argument
 
 echo "*** Testing chr() function: with unexpected inputs for 'ascii' argument
***\n";
 
-//defining a class
-class sample  {
-  public function __toString() {
-    return "sample object";
-  }
-}
-
-//getting the resource
-$file_handle = fopen(__FILE__, "r");
-
 // array with different values for $input
-$inputs =  array (
-
-          // integer values
-/*1*/	  0,
-          1,
-          255,
-          256,
-
-          // float values
-/*5*/	  10.5,
-          -20.5,
-          1.1234e6,
-
-          // boolean values
-/*11*/	  true,
-          false,
-          TRUE,
-          FALSE,
-);
+$inputs = [
+	0,
+	1,
+	255,
+	// float values
+	10.5,
+	// bool values
+	true,
+	false,
+];
 
 // loop through with each element of the $inputs array to test chr() function
 $count = 1;
@@ -44,8 +25,6 @@ foreach($inputs as $input) {
   $count ++;
 }
 
-fclose($file_handle);  //closing the file handle
-
 ?>
 --EXPECTF--
 *** Testing chr() function: with unexpected inputs for 'ascii' argument ***
@@ -56,22 +35,10 @@ string(2) "01"
 -- Iteration 3 --
 string(2) "ff"
 -- Iteration 4 --
-string(2) "00"
--- Iteration 5 --
 
 Deprecated: Implicit conversion from float 10.5 to int loses precision in %s on line %d
 string(2) "0a"
--- Iteration 6 --
-
-Deprecated: Implicit conversion from float -20.5 to int loses precision in %s on line %d
-string(2) "ec"
--- Iteration 7 --
-string(2) "48"
--- Iteration 8 --
-string(2) "01"
--- Iteration 9 --
-string(2) "00"
--- Iteration 10 --
+-- Iteration 5 --
 string(2) "01"
--- Iteration 11 --
+-- Iteration 6 --
 string(2) "00"
diff --git a/ext/standard/tests/strings/str_replace_variation2.phpt
b/ext/standard/tests/strings/str_replace_variation2.phpt
index 957c990555ea5..d8dcd58e1b604 100644
--- a/ext/standard/tests/strings/str_replace_variation2.phpt
+++ b/ext/standard/tests/strings/str_replace_variation2.phpt
@@ -12,7 +12,7 @@ precision=14
 echo "\n*** Testing str_replace() with various subjects ***";
 $subject = "Hello, world,0120333.3445-1.234567          NULL TRUE FALSE\000
         \x000\x5ACD\0abcd \xXYZ\tabcd $$@#%^&*!~,.:;?: !!Hello, World
-        ?Hello, World chr(0).chr(128).chr(234).chr(65).chr(255).chr(256)";
+        ?Hello, World chr(0).chr(128).chr(234).chr(65).chr(255).chr(0)";
 
 /* needles in an array to be compared in the string $string */
 $search_str = array (
@@ -48,7 +48,7 @@ $search_str = array (
   'b',
   '\t',
   "\t",
-  chr(128).chr(234).chr(65).chr(255).chr(256),
+  chr(128).chr(234).chr(65).chr(255).chr(0),
   $subject
 );
 
@@ -65,233 +65,233 @@ for( $i = 0; $i < count($search_str); $i++ ) {
 *** Testing str_replace() with various subjects ***
 --- Iteration 0 ---
 -- String after replacing the search value is => --
-string(181) "Hello, world,0120333.3445-1.234567          NULL TRUE FALSE%0
+string(179) "Hello, world,0120333.3445-1.234567          NULL TRUE FALSE%0
         %00ZCD%0abcd \xXYZ	abcd $$@#%^&*!~,.:;?: !!FOUND
-        ?FOUND chr(0).chr(128).chr(234).chr(65).chr(255).chr(256)"
+        ?FOUND chr(0).chr(128).chr(234).chr(65).chr(255).chr(0)"
 -- search string has found '2' times
 
 --- Iteration 1 ---
 -- String after replacing the search value is => --
-string(181) "Hello, world,0120333.3445-1.234567          NULL TRUE FALSE%0
+string(179) "Hello, world,0120333.3445-1.234567          NULL TRUE FALSE%0
         %00ZCD%0abcd \xXYZ	abcd $$@#%^&*!~,.:;?: !!FOUND
-        ?FOUND chr(0).chr(128).chr(234).chr(65).chr(255).chr(256)"
+        ?FOUND chr(0).chr(128).chr(234).chr(65).chr(255).chr(0)"
 -- search string has found '2' times
 
 --- Iteration 2 ---
 -- String after replacing the search value is => --
-string(186) "Hello, world,0120333.3445-1.234567          NULL TRUE FALSE%0
+string(184) "Hello, world,0120333.3445-1.234567          NULL TRUE FALSE%0
         %00ZCD%0abcd \xXYZ	abcd $$@#%^&*!~,.:;?: FOUND
-        ?Hello, World chr(0).chr(128).chr(234).chr(65).chr(255).chr(256)"
+        ?Hello, World chr(0).chr(128).chr(234).chr(65).chr(255).chr(0)"
 -- search string has found '1' times
 
 --- Iteration 3 ---
 -- String after replacing the search value is => --
-string(195) "Hello, world,0120333.3445-1.234567          NULL TRUE FALSE%0
+string(193) "Hello, world,0120333.3445-1.234567          NULL TRUE FALSE%0
         %00ZCD%0abcd \xXYZ	abcd $$@#%^&*!~,.:;?: !!Hello, World
-        ?Hello, World chr(0).chr(128).chr(234).chr(65).chr(255).chr(256)"
+        ?Hello, World chr(0).chr(128).chr(234).chr(65).chr(255).chr(0)"
 -- search string has found '0' times
 
 --- Iteration 4 ---
 -- String after replacing the search value is => --
-string(186) "Hello, world,0120333.3445-1.234567          NULL TRUE FALSE%0
+string(184) "Hello, world,0120333.3445-1.234567          NULL TRUE FALSE%0
         %00ZCD%0abcd \xXYZ	abcd $FOUND: !!Hello, World
-        ?Hello, World chr(0).chr(128).chr(234).chr(65).chr(255).chr(256)"
+        ?Hello, World chr(0).chr(128).chr(234).chr(65).chr(255).chr(0)"
 -- search string has found '1' times
 
 --- Iteration 5 ---
 -- String after replacing the search value is => --
-string(195) "Hello, world,0120333.3445-1.234567          NULL TRUE FALSE%0
+string(193) "Hello, world,0120333.3445-1.234567          NULL TRUE FALSE%0
         %00ZCD%0abcd \xXYZ	abcd $$@#%^&*!~,.:;?: !!Hello, World
-        ?Hello, World chr(0).chr(128).chr(234).chr(65).chr(255).chr(256)"
+        ?Hello, World chr(0).chr(128).chr(234).chr(65).chr(255).chr(0)"
 -- search string has found '0' times
 
 --- Iteration 6 ---
 -- String after replacing the search value is => --
-string(195) "Hello, world,0120333.3445-1.234567          NULL TRUE FALSE%0
+string(193) "Hello, world,0120333.3445-1.234567          NULL TRUE FALSE%0
         %00ZCD%0abcd \xXYZ	abcd $$@#%^&*!~,.:;?: !!Hello, World
-        ?Hello, World chr(0).chr(128).chr(234).chr(65).chr(255).chr(256)"
+        ?Hello, World chr(0).chr(128).chr(234).chr(65).chr(255).chr(0)"
 -- search string has found '0' times
 
 --- Iteration 7 ---
 -- String after replacing the search value is => --
-string(193) "Hello, world,0120333.3445FOUND67          NULL TRUE FALSE%0
+string(191) "Hello, world,0120333.3445FOUND67          NULL TRUE FALSE%0
         %00ZCD%0abcd \xXYZ	abcd $$@#%^&*!~,.:;?: !!Hello, World
-        ?Hello, World chr(0).chr(128).chr(234).chr(65).chr(255).chr(256)"
+        ?Hello, World chr(0).chr(128).chr(234).chr(65).chr(255).chr(0)"
 -- search string has found '1' times
 
 --- Iteration 8 ---
 -- String after replacing the search value is => --
-string(195) "Hello, world,0120333.3445-1.234567          NULL TRUE FALSE%0
+string(193) "Hello, world,0120333.3445-1.234567          NULL TRUE FALSE%0
         %00ZCD%0abcd \xXYZ	abcd $$@#%^&*!~,.:;?: !!Hello, World
-        ?Hello, World chr(0).chr(128).chr(234).chr(65).chr(255).chr(256)"
+        ?Hello, World chr(0).chr(128).chr(234).chr(65).chr(255).chr(0)"
 -- search string has found '0' times
 
 --- Iteration 9 ---
 -- String after replacing the search value is => --
-string(197) "Hello, world,0120333.3445-1.234567          NULL TRUE FALSE%0
+string(195) "Hello, world,0120333.3445-1.234567          NULL TRUE FALSE%0
         %00ZCD%0FOUND \xXYZ	FOUND $$@#%^&*!~,.:;?: !!Hello, World
-        ?Hello, World chr(0).chr(128).chr(234).chr(65).chr(255).chr(256)"
+        ?Hello, World chr(0).chr(128).chr(234).chr(65).chr(255).chr(0)"
 -- search string has found '2' times
 
 --- Iteration 10 ---
 -- String after replacing the search value is => --
-string(197) "Hello, world,0120333.3445-1.234567          NULL TRUE FALSE%0
+string(195) "Hello, world,0120333.3445-1.234567          NULL TRUE FALSE%0
         %00ZCD%0abcd \xFOUND	abcd $$@#%^&*!~,.:;?: !!Hello, World
-        ?Hello, World chr(0).chr(128).chr(234).chr(65).chr(255).chr(256)"
+        ?Hello, World chr(0).chr(128).chr(234).chr(65).chr(255).chr(0)"
 -- search string has found '1' times
 
 --- Iteration 11 ---
 -- String after replacing the search value is => --
-string(196) "Hello, world,0120333.3445-1.234567          FOUND TRUE FALSE%0
+string(194) "Hello, world,0120333.3445-1.234567          FOUND TRUE FALSE%0
         %00ZCD%0abcd \xXYZ	abcd $$@#%^&*!~,.:;?: !!Hello, World
-        ?Hello, World chr(0).chr(128).chr(234).chr(65).chr(255).chr(256)"
+        ?Hello, World chr(0).chr(128).chr(234).chr(65).chr(255).chr(0)"
 -- search string has found '1' times
 
 --- Iteration 12 ---
 -- String after replacing the search value is => --
-string(211) "Hello, world,FOUND12FOUND333.3445-1.234567          NULL TRUE FALSE%0
+string(213) "Hello, world,FOUND12FOUND333.3445-1.234567          NULL TRUE FALSE%0
         %0FOUNDZCD%0abcd \xXYZ	abcd $$@#%^&*!~,.:;?: !!Hello, World
-        ?Hello, World chr(FOUND).chr(128).chr(234).chr(65).chr(255).chr(256)"
--- search string has found '4' times
+        ?Hello, World chr(FOUND).chr(128).chr(234).chr(65).chr(255).chr(FOUND)"
+-- search string has found '5' times
 
 --- Iteration 13 ---
 -- String after replacing the search value is => --
-string(211) "Hello, world,FOUND12FOUND333.3445-1.234567          NULL TRUE FALSE%0
+string(213) "Hello, world,FOUND12FOUND333.3445-1.234567          NULL TRUE FALSE%0
         %0FOUNDZCD%0abcd \xXYZ	abcd $$@#%^&*!~,.:;?: !!Hello, World
-        ?Hello, World chr(FOUND).chr(128).chr(234).chr(65).chr(255).chr(256)"
--- search string has found '4' times
+        ?Hello, World chr(FOUND).chr(128).chr(234).chr(65).chr(255).chr(FOUND)"
+-- search string has found '5' times
 
 --- Iteration 14 ---
 -- String after replacing the search value is => --
-string(195) "Hello, world,0120333.3445-1.234567          NULL TRUE FALSE%0
+string(193) "Hello, world,0120333.3445-1.234567          NULL TRUE FALSE%0
         %00ZCD%0abcd \xXYZ	abcd $$@#%^&*!~,.:;?: !!Hello, World
-        ?Hello, World chr(0).chr(128).chr(234).chr(65).chr(255).chr(256)"
+        ?Hello, World chr(0).chr(128).chr(234).chr(65).chr(255).chr(0)"
 -- search string has found '0' times
 
 --- Iteration 15 ---
 -- String after replacing the search value is => --
-string(335)
"Hello,FOUNDworld,0120333.3445-1.234567FOUNDFOUNDFOUNDFOUNDFOUNDFOUNDFOUNDFOUNDFOUNDFOUNDNULLFOUNDTRUEFOUNDFALSE%0
+string(333)
"Hello,FOUNDworld,0120333.3445-1.234567FOUNDFOUNDFOUNDFOUNDFOUNDFOUNDFOUNDFOUNDFOUNDFOUNDNULLFOUNDTRUEFOUNDFALSE%0
 FOUNDFOUNDFOUNDFOUNDFOUNDFOUNDFOUNDFOUND%00ZCD%0abcdFOUND\xXYZ	abcdFOUND$$@#%^&*!~,.:;?:FOUND!!Hello,FOUNDWorld
-FOUNDFOUNDFOUNDFOUNDFOUNDFOUNDFOUNDFOUND?Hello,FOUNDWorldFOUNDchr(0).chr(128).chr(234).chr(65).chr(255).chr(256)"
+FOUNDFOUNDFOUNDFOUNDFOUNDFOUNDFOUNDFOUND?Hello,FOUNDWorldFOUNDchr(0).chr(128).chr(234).chr(65).chr(255).chr(0)"
 -- search string has found '35' times
 
 --- Iteration 16 ---
 -- String after replacing the search value is => --
-string(207) "Hello, world,0120333.3445-1.234567          NULL TRUE FALSEFOUND
+string(205) "Hello, world,0120333.3445-1.234567          NULL TRUE FALSEFOUND
         FOUND0ZCDFOUNDabcd \xXYZ	abcd $$@#%^&*!~,.:;?: !!Hello, World
-        ?Hello, World chr(0).chr(128).chr(234).chr(65).chr(255).chr(256)"
+        ?Hello, World chr(0).chr(128).chr(234).chr(65).chr(255).chr(0)"
 -- search string has found '3' times
 
 --- Iteration 17 ---
 -- String after replacing the search value is => --
-string(198) "Hello, world,0120333.3445-1.234567          NULL TRUE FALSE%0
+string(196) "Hello, world,0120333.3445-1.234567          NULL TRUE FALSE%0
         FOUNDZCD%0abcd \xXYZ	abcd $$@#%^&*!~,.:;?: !!Hello, World
-        ?Hello, World chr(0).chr(128).chr(234).chr(65).chr(255).chr(256)"
+        ?Hello, World chr(0).chr(128).chr(234).chr(65).chr(255).chr(0)"
 -- search string has found '1' times
 
 --- Iteration 18 ---
 -- String after replacing the search value is => --
-string(198) "Hello, world,0120333.3445-1.234567          NULL TRUE FALSE%0
+string(196) "Hello, world,0120333.3445-1.234567          NULL TRUE FALSE%0
         %00FOUNDD%0abcd \xXYZ	abcd $$@#%^&*!~,.:;?: !!Hello, World
-        ?Hello, World chr(0).chr(128).chr(234).chr(65).chr(255).chr(256)"
+        ?Hello, World chr(0).chr(128).chr(234).chr(65).chr(255).chr(0)"
 -- search string has found '1' times
 
 --- Iteration 19 ---
 -- String after replacing the search value is => --
-string(198) "Hello, world,0120333.3445-1.234567          NULL TRUE FALSE%0
+string(196) "Hello, world,0120333.3445-1.234567          NULL TRUE FALSE%0
         FOUNDZCD%0abcd \xXYZ	abcd $$@#%^&*!~,.:;?: !!Hello, World
-        ?Hello, World chr(0).chr(128).chr(234).chr(65).chr(255).chr(256)"
+        ?Hello, World chr(0).chr(128).chr(234).chr(65).chr(255).chr(0)"
 -- search string has found '1' times
 
 --- Iteration 20 ---
 -- String after replacing the search value is => --
-string(198) "Hello, world,0120333FOUND445-1.234567          NULL TRUE FALSE%0
+string(196) "Hello, world,0120333FOUND445-1.234567          NULL TRUE FALSE%0
         %00ZCD%0abcd \xXYZ	abcd $$@#%^&*!~,.:;?: !!Hello, World
-        ?Hello, World chr(0).chr(128).chr(234).chr(65).chr(255).chr(256)"
+        ?Hello, World chr(0).chr(128).chr(234).chr(65).chr(255).chr(0)"
 -- search string has found '1' times
 
 --- Iteration 21 ---
 -- String after replacing the search value is => --
-string(207) "Hello, world,0FOUND20333.3445-FOUND.234567          NULL TRUE FALSE%0
+string(205) "Hello, world,0FOUND20333.3445-FOUND.234567          NULL TRUE FALSE%0
         %00ZCD%0abcd \xXYZ	abcd $$@#%^&*!~,.:;?: !!Hello, World
-        ?Hello, World chr(0).chr(FOUND28).chr(234).chr(65).chr(255).chr(256)"
+        ?Hello, World chr(0).chr(FOUND28).chr(234).chr(65).chr(255).chr(0)"
 -- search string has found '3' times
 
 --- Iteration 22 ---
 -- String after replacing the search value is => --
-string(196) "Hello, world,0120333.3445-1.234567          NULL FOUND FALSE%0
+string(194) "Hello, world,0120333.3445-1.234567          NULL FOUND FALSE%0
         %00ZCD%0abcd \xXYZ	abcd $$@#%^&*!~,.:;?: !!Hello, World
-        ?Hello, World chr(0).chr(128).chr(234).chr(65).chr(255).chr(256)"
+        ?Hello, World chr(0).chr(128).chr(234).chr(65).chr(255).chr(0)"
 -- search string has found '1' times
 
 --- Iteration 23 ---
 -- String after replacing the search value is => --
-string(207) "Hello, world,0FOUND20333.3445-FOUND.234567          NULL TRUE FALSE%0
+string(205) "Hello, world,0FOUND20333.3445-FOUND.234567          NULL TRUE FALSE%0
         %00ZCD%0abcd \xXYZ	abcd $$@#%^&*!~,.:;?: !!Hello, World
-        ?Hello, World chr(0).chr(FOUND28).chr(234).chr(65).chr(255).chr(256)"
+        ?Hello, World chr(0).chr(FOUND28).chr(234).chr(65).chr(255).chr(0)"
 -- search string has found '3' times
 
 --- Iteration 24 ---
 -- String after replacing the search value is => --
-string(207) "Hello, world,0FOUND20333.3445-FOUND.234567          NULL TRUE FALSE%0
+string(205) "Hello, world,0FOUND20333.3445-FOUND.234567          NULL TRUE FALSE%0
         %00ZCD%0abcd \xXYZ	abcd $$@#%^&*!~,.:;?: !!Hello, World
-        ?Hello, World chr(0).chr(FOUND28).chr(234).chr(65).chr(255).chr(256)"
+        ?Hello, World chr(0).chr(FOUND28).chr(234).chr(65).chr(255).chr(0)"
 -- search string has found '3' times
 
 --- Iteration 25 ---
 -- String after replacing the search value is => --
-string(195) "Hello, world,0120333.3445-1.234567          NULL TRUE FALSE%0
+string(193) "Hello, world,0120333.3445-1.234567          NULL TRUE FALSE%0
         %00ZCD%0abcd \xXYZ	abcd $$@#%^&*!~,.:;?: !!Hello, World
-        ?Hello, World chr(0).chr(128).chr(234).chr(65).chr(255).chr(256)"
+        ?Hello, World chr(0).chr(128).chr(234).chr(65).chr(255).chr(0)"
 -- search string has found '0' times
 
 --- Iteration 26 ---
 -- String after replacing the search value is => --
-string(195) "Hello, world,0120333.3445-1.234567          NULL TRUE FOUND%0
+string(193) "Hello, world,0120333.3445-1.234567          NULL TRUE FOUND%0
         %00ZCD%0abcd \xXYZ	abcd $$@#%^&*!~,.:;?: !!Hello, World
-        ?Hello, World chr(0).chr(128).chr(234).chr(65).chr(255).chr(256)"
+        ?Hello, World chr(0).chr(128).chr(234).chr(65).chr(255).chr(0)"
 -- search string has found '1' times
 
 --- Iteration 27 ---
 -- String after replacing the search value is => --
-string(335)
"Hello,FOUNDworld,0120333.3445-1.234567FOUNDFOUNDFOUNDFOUNDFOUNDFOUNDFOUNDFOUNDFOUNDFOUNDNULLFOUNDTRUEFOUNDFALSE%0
+string(333)
"Hello,FOUNDworld,0120333.3445-1.234567FOUNDFOUNDFOUNDFOUNDFOUNDFOUNDFOUNDFOUNDFOUNDFOUNDNULLFOUNDTRUEFOUNDFALSE%0
 FOUNDFOUNDFOUNDFOUNDFOUNDFOUNDFOUNDFOUND%00ZCD%0abcdFOUND\xXYZ	abcdFOUND$$@#%^&*!~,.:;?:FOUND!!Hello,FOUNDWorld
-FOUNDFOUNDFOUNDFOUNDFOUNDFOUNDFOUNDFOUND?Hello,FOUNDWorldFOUNDchr(0).chr(128).chr(234).chr(65).chr(255).chr(256)"
+FOUNDFOUNDFOUNDFOUNDFOUNDFOUNDFOUNDFOUND?Hello,FOUNDWorldFOUNDchr(0).chr(128).chr(234).chr(65).chr(255).chr(0)"
 -- search string has found '35' times
 
 --- Iteration 28 ---
 -- String after replacing the search value is => --
-string(190) "Hello, world,0120333.3445-1.234567FOUNDNULL TRUE FALSE%0
+string(188) "Hello, world,0120333.3445-1.234567FOUNDNULL TRUE FALSE%0
         %00ZCD%0abcd \xXYZ	abcd $$@#%^&*!~,.:;?: !!Hello, World
-        ?Hello, World chr(0).chr(128).chr(234).chr(65).chr(255).chr(256)"
+        ?Hello, World chr(0).chr(128).chr(234).chr(65).chr(255).chr(0)"
 -- search string has found '1' times
 
 --- Iteration 29 ---
 -- String after replacing the search value is => --
-string(203) "Hello, world,0120333.3445-1.234567          NULL TRUE FALSE%0
+string(201) "Hello, world,0120333.3445-1.234567          NULL TRUE FALSE%0
         %00ZCD%0aFOUNDcd \xXYZ	aFOUNDcd $$@#%^&*!~,.:;?: !!Hello, World
-        ?Hello, World chr(0).chr(128).chr(234).chr(65).chr(255).chr(256)"
+        ?Hello, World chr(0).chr(128).chr(234).chr(65).chr(255).chr(0)"
 -- search string has found '2' times
 
 --- Iteration 30 ---
 -- String after replacing the search value is => --
-string(195) "Hello, world,0120333.3445-1.234567          NULL TRUE FALSE%0
+string(193) "Hello, world,0120333.3445-1.234567          NULL TRUE FALSE%0
         %00ZCD%0abcd \xXYZ	abcd $$@#%^&*!~,.:;?: !!Hello, World
-        ?Hello, World chr(0).chr(128).chr(234).chr(65).chr(255).chr(256)"
+        ?Hello, World chr(0).chr(128).chr(234).chr(65).chr(255).chr(0)"
 -- search string has found '0' times
 
 --- Iteration 31 ---
 -- String after replacing the search value is => --
-string(199) "Hello, world,0120333.3445-1.234567          NULL TRUE FALSE%0
+string(197) "Hello, world,0120333.3445-1.234567          NULL TRUE FALSE%0
         %00ZCD%0abcd \xXYZFOUNDabcd $$@#%^&*!~,.:;?: !!Hello, World
-        ?Hello, World chr(0).chr(128).chr(234).chr(65).chr(255).chr(256)"
+        ?Hello, World chr(0).chr(128).chr(234).chr(65).chr(255).chr(0)"
 -- search string has found '1' times
 
 --- Iteration 32 ---
 -- String after replacing the search value is => --
-string(195) "Hello, world,0120333.3445-1.234567          NULL TRUE FALSE%0
+string(193) "Hello, world,0120333.3445-1.234567          NULL TRUE FALSE%0
         %00ZCD%0abcd \xXYZ	abcd $$@#%^&*!~,.:;?: !!Hello, World
-        ?Hello, World chr(0).chr(128).chr(234).chr(65).chr(255).chr(256)"
+        ?Hello, World chr(0).chr(128).chr(234).chr(65).chr(255).chr(0)"
 -- search string has found '0' times
 
 --- Iteration 33 ---
diff --git a/ext/standard/tests/strings/strcasecmp.phpt b/ext/standard/tests/strings/strcasecmp.phpt
index e55b2a684fb21..1136774b38acc 100644
--- a/ext/standard/tests/strings/strcasecmp.phpt
+++ b/ext/standard/tests/strings/strcasecmp.phpt
@@ -9,7 +9,7 @@ precision = 12
 echo "#### Basic and Possible operations ####";
 /* creating an array of strings to be compared */
 $arrays = array(
-           array("a", 'A', chr(128), chr(255), chr(256)),
+           array("a", 'A', chr(128), chr(255), chr(0)),
            array("acc", "Acc", 'aC', "acCc",
'acd', "?acc", 'Acc!', "$!acc", ";acc"),
            array("1", "0", 0, "-1", -1, "", TRUE, true,
FALSE, "string"),
            array(10.5, 1.5, 9.5, 11.5, 100.5, 10.5E1, -10.5, 10, 0.5)
diff --git a/ext/standard/tests/strings/strcmp.phpt b/ext/standard/tests/strings/strcmp.phpt
index 5310566d53b60..fa94a9cc3a01a 100644
--- a/ext/standard/tests/strings/strcmp.phpt
+++ b/ext/standard/tests/strings/strcmp.phpt
@@ -9,7 +9,7 @@ precision = 12
 echo "#### Basic and Possible operations ####";
 /* creating an array of strings to be compared */
 $arrays = array(
-           array("a", "A", 'a', 'A', chr(128), chr(255),
chr(256)),
+           array("a", "A", 'a', 'A', chr(128), chr(255),
chr(0)),
            array("acc", "Acc", 'ac', "accc",
'acd', "?acc", 'acc!', "$!acc", ";acc"),
            array("1", "0", 0, "-1", -1, "", TRUE, FALSE,
"string"),
            array(10.5, 1.5, 9.5, 11.5, 100.5, 10.5E1, -10.5, 10, 0.5)
diff --git a/ext/standard/tests/strings/strlen.phpt b/ext/standard/tests/strings/strlen.phpt
index b98111f15e672..b1ff4f4e74d97 100644
--- a/ext/standard/tests/strings/strlen.phpt
+++ b/ext/standard/tests/strings/strlen.phpt
@@ -24,8 +24,8 @@ $strings = array( "Hello, World",
           "\0000",					// len = 2
           "0",
           0,
-          "\t", 					// len = 1
-          '\t', 					// len = 2
+          "\t",						// len = 1
+          '\t',						// len = 2
           TRUE,
           FALSE,
           "Hello, World\0",
@@ -36,7 +36,7 @@ $strings = array( "Hello, World",
           "Hello, World\t",
           "Hello, World\\",
           "              ",
-          chr(128).chr(234).chr(65).chr(255).chr(256),
+          chr(128).chr(234).chr(65).chr(255).chr(0),
 
           "abcdefghijklmnopqrstuvwxyz0123456789~!@#$%^&*()_+=|?><-;:$
                    []{}{{{}}}[[[[]][]]]***&&&^^%$###@@!!@#$%&^&**/////|\\\\\\
@@ -113,11 +113,11 @@ var_dump(strlen("{$str}S"));
 echo "\n--- strlen for long float values ---\n";
 /* Here two different outputs, which depends on the rounding value
    before converting to string. Here Precision = 12  */
-var_dump(strlen(10.55555555555555555555555555));   		// len = 13
-var_dump(strlen(10.55555555595555555555555555));    		// len = 12
+var_dump(strlen(10.55555555555555555555555555));			// len = 13
+var_dump(strlen(10.55555555595555555555555555));			// len = 12
 
 echo "\n--- Nested strlen() ---\n";
-var_dump(strlen(strlen("Hello"))); 				// len=1
+var_dump(strlen(strlen("Hello")));					// len=1
 
 echo "Done\n";
 ?>
diff --git a/ext/standard/tests/strings/strncasecmp_variation6.phpt
b/ext/standard/tests/strings/strncasecmp_variation6.phpt
index 78a0ddd549bf2..3a7b90616a2d2 100644
--- a/ext/standard/tests/strings/strncasecmp_variation6.phpt
+++ b/ext/standard/tests/strings/strncasecmp_variation6.phpt
@@ -10,7 +10,7 @@ echo "*** Test strncasecmp() function: with binary inputs ***\n";
 echo "\n-- Checking with all 256 characters given, in binary format --\n";
 /* loop through to get all 256 character's equivalent binary value, and check working of
strncasecmp() */
 $count = 1;
-for($ASCII = 0; $ASCII <= 255; $ASCII++) {
+for($ASCII = 0; $ASCII < 255; $ASCII++) {
   $str1 = decbin($ASCII);  //ASCII value in binary form
   $str2 = decbin( ord( chr($ASCII) ) );  //Getting equivalent ASCII value for the character in
binary form
   echo "-- Iteration $count --\n";
@@ -21,7 +21,7 @@ for($ASCII = 0; $ASCII <= 255; $ASCII++) {
 
 echo "\n-- Checking with out of character's range, given in binary format --\n";
 $str1 = decbin(256);
-$str2 = decbin( ord( chr(256) ));
+$str2 = decbin( ord( chr(0) ));
 var_dump( strncasecmp($str1, $str2, 8) );  //comparing all the 8-bits; expected: int(1)
 
 echo "\n*** Done ***\n";
@@ -795,9 +795,6 @@ int(0)
 -- Iteration 255 --
 int(0)
 int(0)
--- Iteration 256 --
-int(0)
-int(0)
 
 -- Checking with out of character's range, given in binary format --
 int(1)
diff --git a/ext/standard/tests/strings/strpos_variation1.phpt
b/ext/standard/tests/strings/strpos_variation1.phpt
index f28517316dc46..d01b9eba24d7c 100644
--- a/ext/standard/tests/strings/strpos_variation1.phpt
+++ b/ext/standard/tests/strings/strpos_variation1.phpt
@@ -9,8 +9,8 @@ echo bin2hex( chr(128) ) ." => ";
 var_dump( strpos($string, chr(128)) );
 echo bin2hex( chr(255) ) ." => ";
 var_dump( strpos($string, chr(255), 3) );
-echo bin2hex( chr(256) ) ." => ";
-var_dump( strpos($string, chr(256)) );
+echo bin2hex( chr(0) ) ." => ";
+var_dump( strpos($string, chr(0)) );
 ?>
 
 DONE
diff --git a/ext/standard/tests/strings/strstr_variation1.phpt
b/ext/standard/tests/strings/strstr_variation1.phpt
index aade1fd5f85d4..30699702f8899 100644
--- a/ext/standard/tests/strings/strstr_variation1.phpt
+++ b/ext/standard/tests/strings/strstr_variation1.phpt
@@ -9,8 +9,8 @@ echo bin2hex( chr(128) ) ." => ";
 var_dump( bin2hex( strstr($string, chr(128) ) ) );
 echo bin2hex( chr(255) ) ." => ";
 var_dump( bin2hex( strstr($string, chr(255) ) ) );
-echo bin2hex( chr(256) ) ." => ";
-var_dump( bin2hex( strstr($string, chr(256) ) ) );
+echo bin2hex( chr(0) ) ." => ";
+var_dump( bin2hex( strstr($string, chr(0) ) ) );
 ?>
 
 DONE
diff --git a/ext/standard/tests/strings/substr_count_variation_001.phpt
b/ext/standard/tests/strings/substr_count_variation_001.phpt
index d76c56d60fb21..d7ac3dcd22d62 100644
--- a/ext/standard/tests/strings/substr_count_variation_001.phpt
+++ b/ext/standard/tests/strings/substr_count_variation_001.phpt
@@ -14,10 +14,10 @@ var_dump( substr_count("abcabcabcabcabc", "abca") );
 var_dump( substr_count("abcabcabcabcabc", "abca", 2) );
 
 echo "\n-- complex strings containing other than 7-bit chars --\n";
-$str = chr(128).chr(129).chr(128).chr(256).chr(255).chr(254).chr(255);
+$str = chr(128).chr(129).chr(128).chr(0).chr(255).chr(254).chr(255);
 var_dump(substr_count($str, chr(128)));
 var_dump(substr_count($str, chr(255)));
-var_dump(substr_count($str, chr(256)));
+var_dump(substr_count($str, chr(0)));
 
 echo "\n-- heredoc string --\n";
 $string = <<<EOD
diff --git a/ext/standard/tests/strings/substr_count_variation_002.phpt
b/ext/standard/tests/strings/substr_count_variation_002.phpt
index 29b8afd9f5a38..9bf41dab4c066 100644
--- a/ext/standard/tests/strings/substr_count_variation_002.phpt
+++ b/ext/standard/tests/strings/substr_count_variation_002.phpt
@@ -5,10 +5,10 @@ Test substr_count() function (variation - 2)
 
 echo "\n*** Testing possible variations ***\n";
 echo "\n-- complex strings containing other than 7-bit chars --\n";
-$str = chr(128).chr(129).chr(128).chr(256).chr(255).chr(254).chr(255);
+$str = chr(128).chr(129).chr(128).chr(0).chr(255).chr(254).chr(255);
 var_dump(substr_count($str, chr(128)));
 var_dump(substr_count($str, chr(255)));
-var_dump(substr_count($str, chr(256)));
+var_dump(substr_count($str, chr(0)));
 
 echo "\n-- heredoc string --\n";
 $string = <<<EOD


Thread (1 message)

  • Gina Peter Banyard via GitHub
« previous php.cvs (#135288) next »