php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login

Patch 61813.diff for *General Issues Bug #61813

Patch version 2012-04-23 08:07 UTC

Return to Bug #61813 | Download this patch
Patch Revisions:

Developer: ab@php.net

diff --git a/ext/standard/tests/strings/strrchr_variation5.phpt b/ext/standard/tests/strings/strrchr_variation5.phpt
index 1ef2391..2f0a47b 100644
--- a/ext/standard/tests/strings/strrchr_variation5.phpt
+++ b/ext/standard/tests/strings/strrchr_variation5.phpt
@@ -1,5 +1,10 @@
 --TEST--
 Test strrchr() function : usage variations - heredoc string containing escape sequences for 'haystack'
+--SKIPIF--
+<?php
+if(substr(PHP_OS, 0, 3) == 'WIN' ) {
+	die('skip non windows test');
+}
 --FILE--
 <?php
 /* Prototype  : string strrchr(string $haystack, string $needle);
--- a/ext/standard/tests/strings/strrchr_variation5-win.phpt	Mon Apr 23 10:03:24 2012
+++ b/ext/standard/tests/strings/strrchr_variation5-win.phpt	Mon Apr 23 10:03:24 2012
@@ -0,0 +1,55 @@
+--TEST--
+Test strrchr() function : usage variations - heredoc string containing escape sequences for 'haystack'
+--SKIPIF--
+<?php
+if(substr(PHP_OS, 0, 3) != 'WIN' ) {
+	die('skip windows only test');
+}
+--FILE--
+<?php
+/* Prototype  : string strrchr(string $haystack, string $needle);
+ * Description: Finds the last occurrence of a character in a string.
+ * Source code: ext/standard/string.c
+*/
+
+/* Test strrchr() function by passing heredoc string containing 
+ *  escape sequences for haystack and with various needles
+*/
+
+echo "*** Testing strrchr() function: with heredoc strings ***\n";
+$escape_char_str = <<<EOD
+\tes\t st\r\rch\r using
+\escape \\seque\nce
+EOD;
+
+$needles = array(
+  "\t",
+  '\n',
+  "\r",
+  "\\",
+  $escape_char_str //needle as haystack
+);
+
+//loop through to test strrchr() with each needle
+foreach($needles as $needle) {
+  var_dump( strrchr($escape_char_str, $needle) );
+}
+
+echo "*** Done ***";
+?>
+--EXPECTF--
+*** Testing strrchr() function: with heredoc strings ***
+string(32) "	 st

ch
 using
+escape \seque
+ce"
+string(9) "\seque
+ce"
+string(24) "
 using
+escape \seque
+ce"
+string(9) "\seque
+ce"
+string(32) "	 st

ch
 using
+escape \seque
+ce"
+*** Done ***
 
PHP Copyright © 2001-2025 The PHP Group
All rights reserved.
Last updated: Sun Jul 13 18:01:32 2025 UTC