1--TEST-- 2Test strncasecmp() function: usage variations - heredoc strings 3--FILE-- 4<?php 5/* Prototype : int strncasecmp ( string $str1, string $str2, int $len ); 6 * Description: Binary safe case-insensitive string comparison of the first n characters 7 * Source code: Zend/zend_builtin_functions.c 8*/ 9 10/* Test strncasecmp() function with here-doc strings for 'str1', 'str2' */ 11 12echo "*** Test strncasecmp() function: with here-doc strings ***\n"; 13 14/* multi line heredoc string */ 15$multi_line_str = <<<EOD 16Example of string 17spanning multiple lines 18using heredoc syntax. 19EOD; 20 21/* identifier name contains underscore */ 22$identifier_str1 = <<<identifier_str1 23Example of heredoc 24string, whose identifier 25having underscore("_") 26& numeric value. 27identifier_str1; 28 29/* identifier name starts with underscore */ 30$identifier_str2 = <<<_identifier_str2 31Hello, World 32hello, world 33_identifier_str2; 34 35/* string containing control character */ 36$control_char_str = <<<EOD 37Hello, World\n 38Hello\0World 39EOD; 40 41/* heredoc string with quote chars & slash */ 42$quote_char_string = <<<EOD 43it's bright,but i cann't see it. 44"things in double quote" 45'things in single quote' 46this\line is /with\slashs 47EOD; 48 49/* heredoc string with blank line */ 50$blank_line = <<<EOD 51 52EOD; 53 54/* empty heredoc string */ 55$empty_string = <<<EOD 56EOD; 57 58$strings = array( 59 $multi_line_str, 60 $identifier_str1, 61 $identifier_str2, 62 $control_char_str, 63 $quote_char_string, 64 $blank_line, 65 $empty_string 66); 67/* loop through to compare the strings */ 68$index2 = count($strings); 69for($index1 = 0; $index1 < count($strings); $index1++) { 70 $index2--; 71 var_dump( strncasecmp( $strings[$index1], $strings[$index1], strlen($strings[$index1]) ) ); 72 var_dump( strncasecmp( $strings[$index1], $strings[$index2], strlen($strings[$index1]) ) ); 73} 74echo "*** Done ***\n"; 75?> 76--EXPECT-- 77*** Test strncasecmp() function: with here-doc strings *** 78int(0) 79int(63) 80int(0) 81int(84) 82int(0) 83int(-1) 84int(0) 85int(0) 86int(0) 87int(1) 88int(0) 89int(0) 90int(0) 91int(0) 92*** Done *** 93