1--TEST-- 2Test str_replace() function 3--INI-- 4precision=14 5--FILE-- 6<?php 7/* 8 Prototype: mixed str_replace(mixed $search, mixed $replace, 9 mixed $subject [, int &$count]); 10 Description: Replace all occurrences of the search string with 11 the replacement string 12*/ 13 14echo "\n*** Testing str_replace() on basic operations ***\n"; 15 16var_dump( str_replace("", "", "") ); 17 18var_dump( str_replace("e", "b", "test") ); 19 20var_dump( str_replace("", "", "", $count) ); 21var_dump( $count ); 22 23var_dump( str_replace("q", "q", "q", $count) ); 24var_dump( $count ); 25 26var_dump( str_replace("long string here", "", "", $count) ); 27var_dump( $count ); 28 29$fp = fopen( __FILE__, "r" ); 30$fp_copy = $fp; 31var_dump( str_replace($fp_copy, $fp_copy, $fp_copy, $fp_copy) ); 32var_dump( $fp_copy ); 33fclose($fp); 34 35echo "\n*** Testing str_replace() with various search values ***"; 36$search_arr = array( TRUE, FALSE, 1, 0, -1, "1", "0", "-1", NULL, 37 array(), "php", ""); 38 39$i = 0; 40/* loop through to replace the matched elements in the array */ 41foreach( $search_arr as $value ) { 42 echo "\n-- Iteration $i --\n"; 43 /* replace the string in array */ 44 var_dump( str_replace($value, "FOUND", $search_arr, $count) ); 45 var_dump( $count ); 46 $i++; 47} 48 49echo "\n*** Testing str_replace() with various subjects ***"; 50$subject = "Hello, world,0120333.3445-1.234567 NULL TRUE FALSE\000 51 \x000\xABCD\0abcd \xXYZ\tabcd $$@#%^&*!~,.:;?: !!Hello, World 52 ?Hello, World chr(0).chr(128).chr(234).chr(65).chr(255).chr(256)"; 53 54/* needles in an array to be compared in the string $string */ 55$search_str = array ( 56 "Hello, World", 57 'Hello, World', 58 '!!Hello, World', 59 "??Hello, World", 60 "$@#%^&*!~,.:;?", 61 "123", 62 123, 63 "-1.2345", 64 -1.2344, 65 "abcd", 66 'XYZ', 67 NULL, 68 "NULL", 69 "0", 70 0, 71 "", 72 " ", 73 "\0", 74 "\x000", 75 "\xABC", 76 "\0000", 77 ".3", 78 TRUE, 79 "TRUE", 80 "1", 81 1, 82 FALSE, 83 "FALSE", 84 " ", 85 " ", 86 'b', 87 '\t', 88 "\t", 89 chr(128).chr(234).chr(65).chr(255).chr(256), 90 $subject 91); 92 93/* loop through to get the $string */ 94for( $i = 0; $i < count($search_str); $i++ ) { 95 echo "\n--- Iteration $i ---"; 96 echo "\n-- String after replacing the search value is => --\n"; 97 var_dump( str_replace($search_str[$i], "FOUND", $subject, $count) ); 98 echo "-- search string has found '$count' times\n"; 99} 100 101 102echo "\n*** Testing Miscelleneous input data ***\n"; 103/* If replace has fewer values than search, then an empty 104 string is used for the rest of replacement values */ 105var_dump( str_replace(array("a", "a", "b"), 106 array("q", "q"), 107 "aaabb", $count 108 ) 109 ); 110var_dump($count); 111var_dump( str_replace(array("a", "a", "b"), 112 array("q", "q"), 113 array("aaa", "bbb", "ccc"), 114 $count 115 ) 116 ); 117var_dump($count); 118 119 120echo "\n-- Testing objects --\n"; 121/* we get "Catchable fatal error: saying Object of class could not be converted 122 to string" by default, when an object is passed instead of string: 123The error can be avoided by choosing the __toString magix method as follows: */ 124 125class subject 126{ 127 function __toString() { 128 return "Hello, world"; 129 } 130} 131$obj_subject = new subject; 132 133class search 134{ 135 function __toString() { 136 return "Hello, world"; 137 } 138} 139$obj_search = new search; 140 141class replace 142{ 143 function __toString() { 144 return "Hello, world"; 145 } 146} 147$obj_replace = new replace; 148 149var_dump(str_replace("$obj_search", "$obj_replace", "$obj_subject", $count)); 150var_dump($count); 151 152 153echo "\n-- Testing arrays --\n"; 154var_dump(str_replace(array("a", "a", "b"), "multi", "aaa", $count)); 155var_dump($count); 156 157var_dump(str_replace( array("a", "a", "b"), 158 array("q", "q", "c"), 159 "aaa", $count 160 ) 161); 162var_dump($count); 163 164var_dump(str_replace( array("a", "a", "b"), 165 array("q", "q", "c"), 166 array("aaa", "bbb"), 167 $count 168 ) 169); 170var_dump($count); 171 172var_dump(str_replace("a", array("q", "q", "c"), array("aaa", "bbb"), $count)); 173var_dump($count); 174 175var_dump(str_replace("a", 1, array("aaa", "bbb"), $count)); 176var_dump($count); 177 178var_dump(str_replace(1, 3, array("aaa1", "2bbb"), $count)); 179var_dump($count); 180 181 182echo "\n-- Testing Resources --\n"; 183$resource1 = fopen( __FILE__, "r" ); 184$resource2 = opendir( "." ); 185var_dump(str_replace("stream", "FOUND", $resource1, $count)); 186var_dump($count); 187var_dump(str_replace("stream", "FOUND", $resource2, $count)); 188var_dump($count); 189 190 191echo "\n-- Testing a longer and heredoc string --\n"; 192$string = <<<EOD 193abcdefghijklmnopqrstuvwxyz0123456789abcdefghijklmnopqrstuvwxyz0123456789 194abcdefghijklmnopqrstuvwxyz0123456789abcdefghijklmnopqrstuvwxyz0123456789 195abcdefghijklmnopqrstuvwxyz0123456789abcdefghijklmnopqrstuvwxyz0123456789 196abcdefghijklmnopqrstuvwxyz0123456789abcdefghijklmnopqrstuvwxyz0123456789 197abcdefghijklmnopqrstuvwxyz0123456789abcdefghijklmnopqrstuvwxyz0123456789 198abcdefghijklmnopqrstuvwxyz0123456789abcdefghijklmnopqrstuvwxyz0123456789 199abcdefghijklmnopqrstuvwxyz0123456789abcdefghijklmnopqrstuvwxyz0123456789 200@#$%^&**&^%$#@!~:())))((((&&&**%$###@@@!!!~~~~@###$%^&* 201abcdefghijklmnopqrstuvwxyz0123456789abcdefghijklmnopqrstuvwxyz0123456789 202EOD; 203 204var_dump( str_replace("abcdef", "FOUND", $string, $count) ); 205var_dump( $count ); 206 207echo "\n-- Testing a heredoc null string --\n"; 208$str = <<<EOD 209EOD; 210var_dump( str_replace("", "FOUND", $str, $count) ); 211var_dump( $count ); 212 213 214echo "\n-- Testing simple and complex syntax strings --\n"; 215$str = 'world'; 216 217/* Simple syntax */ 218var_dump( str_replace("world", "FOUND", "$str") ); 219var_dump( str_replace("world'S", "FOUND", "$str'S") ); 220var_dump( str_replace("worldS", "FOUND", "$strS") ); 221 222/* String with curly braces, complex syntax */ 223var_dump( str_replace("worldS", "FOUND", "${str}S") ); 224var_dump( str_replace("worldS", "FOUND", "{$str}S") ); 225 226 227echo "\n*** Testing error conditions ***"; 228/* Invalid arguments */ 229var_dump( str_replace() ); 230var_dump( str_replace("") ); 231var_dump( str_replace(NULL) ); 232var_dump( str_replace(1, 2) ); 233var_dump( str_replace(1,2,3,$var,5) ); 234 235fclose($resource1); 236closedir($resource2); 237echo "Done\n"; 238 239?> 240--EXPECTF-- 241*** Testing str_replace() on basic operations *** 242string(0) "" 243string(4) "tbst" 244string(0) "" 245int(0) 246string(1) "q" 247int(1) 248string(0) "" 249int(0) 250string(%d) "Resource id #%d" 251int(1) 252 253*** Testing str_replace() with various search values *** 254-- Iteration 0 -- 255array(12) { 256 [0]=> 257 string(5) "FOUND" 258 [1]=> 259 string(0) "" 260 [2]=> 261 string(5) "FOUND" 262 [3]=> 263 string(1) "0" 264 [4]=> 265 string(6) "-FOUND" 266 [5]=> 267 string(5) "FOUND" 268 [6]=> 269 string(1) "0" 270 [7]=> 271 string(6) "-FOUND" 272 [8]=> 273 string(0) "" 274 [9]=> 275 array(0) { 276 } 277 [10]=> 278 string(3) "php" 279 [11]=> 280 string(0) "" 281} 282int(5) 283 284-- Iteration 1 -- 285array(12) { 286 [0]=> 287 string(1) "1" 288 [1]=> 289 string(0) "" 290 [2]=> 291 string(1) "1" 292 [3]=> 293 string(1) "0" 294 [4]=> 295 string(2) "-1" 296 [5]=> 297 string(1) "1" 298 [6]=> 299 string(1) "0" 300 [7]=> 301 string(2) "-1" 302 [8]=> 303 string(0) "" 304 [9]=> 305 array(0) { 306 } 307 [10]=> 308 string(3) "php" 309 [11]=> 310 string(0) "" 311} 312int(0) 313 314-- Iteration 2 -- 315array(12) { 316 [0]=> 317 string(5) "FOUND" 318 [1]=> 319 string(0) "" 320 [2]=> 321 string(5) "FOUND" 322 [3]=> 323 string(1) "0" 324 [4]=> 325 string(6) "-FOUND" 326 [5]=> 327 string(5) "FOUND" 328 [6]=> 329 string(1) "0" 330 [7]=> 331 string(6) "-FOUND" 332 [8]=> 333 string(0) "" 334 [9]=> 335 array(0) { 336 } 337 [10]=> 338 string(3) "php" 339 [11]=> 340 string(0) "" 341} 342int(5) 343 344-- Iteration 3 -- 345array(12) { 346 [0]=> 347 string(1) "1" 348 [1]=> 349 string(0) "" 350 [2]=> 351 string(1) "1" 352 [3]=> 353 string(5) "FOUND" 354 [4]=> 355 string(2) "-1" 356 [5]=> 357 string(1) "1" 358 [6]=> 359 string(5) "FOUND" 360 [7]=> 361 string(2) "-1" 362 [8]=> 363 string(0) "" 364 [9]=> 365 array(0) { 366 } 367 [10]=> 368 string(3) "php" 369 [11]=> 370 string(0) "" 371} 372int(2) 373 374-- Iteration 4 -- 375array(12) { 376 [0]=> 377 string(1) "1" 378 [1]=> 379 string(0) "" 380 [2]=> 381 string(1) "1" 382 [3]=> 383 string(1) "0" 384 [4]=> 385 string(5) "FOUND" 386 [5]=> 387 string(1) "1" 388 [6]=> 389 string(1) "0" 390 [7]=> 391 string(5) "FOUND" 392 [8]=> 393 string(0) "" 394 [9]=> 395 array(0) { 396 } 397 [10]=> 398 string(3) "php" 399 [11]=> 400 string(0) "" 401} 402int(2) 403 404-- Iteration 5 -- 405array(12) { 406 [0]=> 407 string(5) "FOUND" 408 [1]=> 409 string(0) "" 410 [2]=> 411 string(5) "FOUND" 412 [3]=> 413 string(1) "0" 414 [4]=> 415 string(6) "-FOUND" 416 [5]=> 417 string(5) "FOUND" 418 [6]=> 419 string(1) "0" 420 [7]=> 421 string(6) "-FOUND" 422 [8]=> 423 string(0) "" 424 [9]=> 425 array(0) { 426 } 427 [10]=> 428 string(3) "php" 429 [11]=> 430 string(0) "" 431} 432int(5) 433 434-- Iteration 6 -- 435array(12) { 436 [0]=> 437 string(1) "1" 438 [1]=> 439 string(0) "" 440 [2]=> 441 string(1) "1" 442 [3]=> 443 string(5) "FOUND" 444 [4]=> 445 string(2) "-1" 446 [5]=> 447 string(1) "1" 448 [6]=> 449 string(5) "FOUND" 450 [7]=> 451 string(2) "-1" 452 [8]=> 453 string(0) "" 454 [9]=> 455 array(0) { 456 } 457 [10]=> 458 string(3) "php" 459 [11]=> 460 string(0) "" 461} 462int(2) 463 464-- Iteration 7 -- 465array(12) { 466 [0]=> 467 string(1) "1" 468 [1]=> 469 string(0) "" 470 [2]=> 471 string(1) "1" 472 [3]=> 473 string(1) "0" 474 [4]=> 475 string(5) "FOUND" 476 [5]=> 477 string(1) "1" 478 [6]=> 479 string(1) "0" 480 [7]=> 481 string(5) "FOUND" 482 [8]=> 483 string(0) "" 484 [9]=> 485 array(0) { 486 } 487 [10]=> 488 string(3) "php" 489 [11]=> 490 string(0) "" 491} 492int(2) 493 494-- Iteration 8 -- 495array(12) { 496 [0]=> 497 string(1) "1" 498 [1]=> 499 string(0) "" 500 [2]=> 501 string(1) "1" 502 [3]=> 503 string(1) "0" 504 [4]=> 505 string(2) "-1" 506 [5]=> 507 string(1) "1" 508 [6]=> 509 string(1) "0" 510 [7]=> 511 string(2) "-1" 512 [8]=> 513 string(0) "" 514 [9]=> 515 array(0) { 516 } 517 [10]=> 518 string(3) "php" 519 [11]=> 520 string(0) "" 521} 522int(0) 523 524-- Iteration 9 -- 525array(12) { 526 [0]=> 527 string(1) "1" 528 [1]=> 529 string(0) "" 530 [2]=> 531 string(1) "1" 532 [3]=> 533 string(1) "0" 534 [4]=> 535 string(2) "-1" 536 [5]=> 537 string(1) "1" 538 [6]=> 539 string(1) "0" 540 [7]=> 541 string(2) "-1" 542 [8]=> 543 string(0) "" 544 [9]=> 545 array(0) { 546 } 547 [10]=> 548 string(3) "php" 549 [11]=> 550 string(0) "" 551} 552int(0) 553 554-- Iteration 10 -- 555array(12) { 556 [0]=> 557 string(1) "1" 558 [1]=> 559 string(0) "" 560 [2]=> 561 string(1) "1" 562 [3]=> 563 string(1) "0" 564 [4]=> 565 string(2) "-1" 566 [5]=> 567 string(1) "1" 568 [6]=> 569 string(1) "0" 570 [7]=> 571 string(2) "-1" 572 [8]=> 573 string(0) "" 574 [9]=> 575 array(0) { 576 } 577 [10]=> 578 string(5) "FOUND" 579 [11]=> 580 string(0) "" 581} 582int(1) 583 584-- Iteration 11 -- 585array(12) { 586 [0]=> 587 string(1) "1" 588 [1]=> 589 string(0) "" 590 [2]=> 591 string(1) "1" 592 [3]=> 593 string(1) "0" 594 [4]=> 595 string(2) "-1" 596 [5]=> 597 string(1) "1" 598 [6]=> 599 string(1) "0" 600 [7]=> 601 string(2) "-1" 602 [8]=> 603 string(0) "" 604 [9]=> 605 array(0) { 606 } 607 [10]=> 608 string(3) "php" 609 [11]=> 610 string(0) "" 611} 612int(0) 613 614*** Testing str_replace() with various subjects *** 615--- Iteration 0 --- 616-- String after replacing the search value is => -- 617string(177) "Hello, world,0120333.3445-1.234567 NULL TRUE FALSE 618 0�CDabcd \xXYZ abcd $$@#%^&*!~,.:;?: !!FOUND 619 ?FOUND chr(0).chr(128).chr(234).chr(65).chr(255).chr(256)" 620-- search string has found '2' times 621 622--- Iteration 1 --- 623-- String after replacing the search value is => -- 624string(177) "Hello, world,0120333.3445-1.234567 NULL TRUE FALSE 625 0�CDabcd \xXYZ abcd $$@#%^&*!~,.:;?: !!FOUND 626 ?FOUND chr(0).chr(128).chr(234).chr(65).chr(255).chr(256)" 627-- search string has found '2' times 628 629--- Iteration 2 --- 630-- String after replacing the search value is => -- 631string(182) "Hello, world,0120333.3445-1.234567 NULL TRUE FALSE 632 0�CDabcd \xXYZ abcd $$@#%^&*!~,.:;?: FOUND 633 ?Hello, World chr(0).chr(128).chr(234).chr(65).chr(255).chr(256)" 634-- search string has found '1' times 635 636--- Iteration 3 --- 637-- String after replacing the search value is => -- 638string(191) "Hello, world,0120333.3445-1.234567 NULL TRUE FALSE 639 0�CDabcd \xXYZ abcd $$@#%^&*!~,.:;?: !!Hello, World 640 ?Hello, World chr(0).chr(128).chr(234).chr(65).chr(255).chr(256)" 641-- search string has found '0' times 642 643--- Iteration 4 --- 644-- String after replacing the search value is => -- 645string(182) "Hello, world,0120333.3445-1.234567 NULL TRUE FALSE 646 0�CDabcd \xXYZ abcd $FOUND: !!Hello, World 647 ?Hello, World chr(0).chr(128).chr(234).chr(65).chr(255).chr(256)" 648-- search string has found '1' times 649 650--- Iteration 5 --- 651-- String after replacing the search value is => -- 652string(191) "Hello, world,0120333.3445-1.234567 NULL TRUE FALSE 653 0�CDabcd \xXYZ abcd $$@#%^&*!~,.:;?: !!Hello, World 654 ?Hello, World chr(0).chr(128).chr(234).chr(65).chr(255).chr(256)" 655-- search string has found '0' times 656 657--- Iteration 6 --- 658-- String after replacing the search value is => -- 659string(191) "Hello, world,0120333.3445-1.234567 NULL TRUE FALSE 660 0�CDabcd \xXYZ abcd $$@#%^&*!~,.:;?: !!Hello, World 661 ?Hello, World chr(0).chr(128).chr(234).chr(65).chr(255).chr(256)" 662-- search string has found '0' times 663 664--- Iteration 7 --- 665-- String after replacing the search value is => -- 666string(189) "Hello, world,0120333.3445FOUND67 NULL TRUE FALSE 667 0�CDabcd \xXYZ abcd $$@#%^&*!~,.:;?: !!Hello, World 668 ?Hello, World chr(0).chr(128).chr(234).chr(65).chr(255).chr(256)" 669-- search string has found '1' times 670 671--- Iteration 8 --- 672-- String after replacing the search value is => -- 673string(191) "Hello, world,0120333.3445-1.234567 NULL TRUE FALSE 674 0�CDabcd \xXYZ abcd $$@#%^&*!~,.:;?: !!Hello, World 675 ?Hello, World chr(0).chr(128).chr(234).chr(65).chr(255).chr(256)" 676-- search string has found '0' times 677 678--- Iteration 9 --- 679-- String after replacing the search value is => -- 680string(193) "Hello, world,0120333.3445-1.234567 NULL TRUE FALSE 681 0�CDFOUND \xXYZ FOUND $$@#%^&*!~,.:;?: !!Hello, World 682 ?Hello, World chr(0).chr(128).chr(234).chr(65).chr(255).chr(256)" 683-- search string has found '2' times 684 685--- Iteration 10 --- 686-- String after replacing the search value is => -- 687string(193) "Hello, world,0120333.3445-1.234567 NULL TRUE FALSE 688 0�CDabcd \xFOUND abcd $$@#%^&*!~,.:;?: !!Hello, World 689 ?Hello, World chr(0).chr(128).chr(234).chr(65).chr(255).chr(256)" 690-- search string has found '1' times 691 692--- Iteration 11 --- 693-- String after replacing the search value is => -- 694string(191) "Hello, world,0120333.3445-1.234567 NULL TRUE FALSE 695 0�CDabcd \xXYZ abcd $$@#%^&*!~,.:;?: !!Hello, World 696 ?Hello, World chr(0).chr(128).chr(234).chr(65).chr(255).chr(256)" 697-- search string has found '0' times 698 699--- Iteration 12 --- 700-- String after replacing the search value is => -- 701string(192) "Hello, world,0120333.3445-1.234567 FOUND TRUE FALSE 702 0�CDabcd \xXYZ abcd $$@#%^&*!~,.:;?: !!Hello, World 703 ?Hello, World chr(0).chr(128).chr(234).chr(65).chr(255).chr(256)" 704-- search string has found '1' times 705 706--- Iteration 13 --- 707-- String after replacing the search value is => -- 708string(207) "Hello, world,FOUND12FOUND333.3445-1.234567 NULL TRUE FALSE 709 FOUND�CDabcd \xXYZ abcd $$@#%^&*!~,.:;?: !!Hello, World 710 ?Hello, World chr(FOUND).chr(128).chr(234).chr(65).chr(255).chr(256)" 711-- search string has found '4' times 712 713--- Iteration 14 --- 714-- String after replacing the search value is => -- 715string(207) "Hello, world,FOUND12FOUND333.3445-1.234567 NULL TRUE FALSE 716 FOUND�CDabcd \xXYZ abcd $$@#%^&*!~,.:;?: !!Hello, World 717 ?Hello, World chr(FOUND).chr(128).chr(234).chr(65).chr(255).chr(256)" 718-- search string has found '4' times 719 720--- Iteration 15 --- 721-- String after replacing the search value is => -- 722string(191) "Hello, world,0120333.3445-1.234567 NULL TRUE FALSE 723 0�CDabcd \xXYZ abcd $$@#%^&*!~,.:;?: !!Hello, World 724 ?Hello, World chr(0).chr(128).chr(234).chr(65).chr(255).chr(256)" 725-- search string has found '0' times 726 727--- Iteration 16 --- 728-- String after replacing the search value is => -- 729string(307) "Hello,FOUNDworld,0120333.3445-1.234567FOUNDFOUNDFOUNDFOUNDFOUNDFOUNDFOUNDFOUNDFOUNDFOUNDNULLFOUNDTRUEFOUNDFALSE 730FOUND FOUNDFOUNDFOUNDFOUND0�CDabcdFOUND\xXYZ abcdFOUND$$@#%^&*!~,.:;?:FOUND!!Hello,FOUNDWorldFOUND 731 FOUNDFOUNDFOUNDFOUND?Hello,FOUNDWorldFOUNDchr(0).chr(128).chr(234).chr(65).chr(255).chr(256)" 732-- search string has found '29' times 733 734--- Iteration 17 --- 735-- String after replacing the search value is => -- 736string(203) "Hello, world,0120333.3445-1.234567 NULL TRUE FALSEFOUND 737 FOUND0�CDFOUNDabcd \xXYZ abcd $$@#%^&*!~,.:;?: !!Hello, World 738 ?Hello, World chr(0).chr(128).chr(234).chr(65).chr(255).chr(256)" 739-- search string has found '3' times 740 741--- Iteration 18 --- 742-- String after replacing the search value is => -- 743string(194) "Hello, world,0120333.3445-1.234567 NULL TRUE FALSE 744 FOUND�CDabcd \xXYZ abcd $$@#%^&*!~,.:;?: !!Hello, World 745 ?Hello, World chr(0).chr(128).chr(234).chr(65).chr(255).chr(256)" 746-- search string has found '1' times 747 748--- Iteration 19 --- 749-- String after replacing the search value is => -- 750string(194) "Hello, world,0120333.3445-1.234567 NULL TRUE FALSE 751 0FOUNDDabcd \xXYZ abcd $$@#%^&*!~,.:;?: !!Hello, World 752 ?Hello, World chr(0).chr(128).chr(234).chr(65).chr(255).chr(256)" 753-- search string has found '1' times 754 755--- Iteration 20 --- 756-- String after replacing the search value is => -- 757string(194) "Hello, world,0120333.3445-1.234567 NULL TRUE FALSE 758 FOUND�CDabcd \xXYZ abcd $$@#%^&*!~,.:;?: !!Hello, World 759 ?Hello, World chr(0).chr(128).chr(234).chr(65).chr(255).chr(256)" 760-- search string has found '1' times 761 762--- Iteration 21 --- 763-- String after replacing the search value is => -- 764string(194) "Hello, world,0120333FOUND445-1.234567 NULL TRUE FALSE 765 0�CDabcd \xXYZ abcd $$@#%^&*!~,.:;?: !!Hello, World 766 ?Hello, World chr(0).chr(128).chr(234).chr(65).chr(255).chr(256)" 767-- search string has found '1' times 768 769--- Iteration 22 --- 770-- String after replacing the search value is => -- 771string(203) "Hello, world,0FOUND20333.3445-FOUND.234567 NULL TRUE FALSE 772 0�CDabcd \xXYZ abcd $$@#%^&*!~,.:;?: !!Hello, World 773 ?Hello, World chr(0).chr(FOUND28).chr(234).chr(65).chr(255).chr(256)" 774-- search string has found '3' times 775 776--- Iteration 23 --- 777-- String after replacing the search value is => -- 778string(192) "Hello, world,0120333.3445-1.234567 NULL FOUND FALSE 779 0�CDabcd \xXYZ abcd $$@#%^&*!~,.:;?: !!Hello, World 780 ?Hello, World chr(0).chr(128).chr(234).chr(65).chr(255).chr(256)" 781-- search string has found '1' times 782 783--- Iteration 24 --- 784-- String after replacing the search value is => -- 785string(203) "Hello, world,0FOUND20333.3445-FOUND.234567 NULL TRUE FALSE 786 0�CDabcd \xXYZ abcd $$@#%^&*!~,.:;?: !!Hello, World 787 ?Hello, World chr(0).chr(FOUND28).chr(234).chr(65).chr(255).chr(256)" 788-- search string has found '3' times 789 790--- Iteration 25 --- 791-- String after replacing the search value is => -- 792string(203) "Hello, world,0FOUND20333.3445-FOUND.234567 NULL TRUE FALSE 793 0�CDabcd \xXYZ abcd $$@#%^&*!~,.:;?: !!Hello, World 794 ?Hello, World chr(0).chr(FOUND28).chr(234).chr(65).chr(255).chr(256)" 795-- search string has found '3' times 796 797--- Iteration 26 --- 798-- String after replacing the search value is => -- 799string(191) "Hello, world,0120333.3445-1.234567 NULL TRUE FALSE 800 0�CDabcd \xXYZ abcd $$@#%^&*!~,.:;?: !!Hello, World 801 ?Hello, World chr(0).chr(128).chr(234).chr(65).chr(255).chr(256)" 802-- search string has found '0' times 803 804--- Iteration 27 --- 805-- String after replacing the search value is => -- 806string(191) "Hello, world,0120333.3445-1.234567 NULL TRUE FOUND 807 0�CDabcd \xXYZ abcd $$@#%^&*!~,.:;?: !!Hello, World 808 ?Hello, World chr(0).chr(128).chr(234).chr(65).chr(255).chr(256)" 809-- search string has found '1' times 810 811--- Iteration 28 --- 812-- String after replacing the search value is => -- 813string(307) "Hello,FOUNDworld,0120333.3445-1.234567FOUNDFOUNDFOUNDFOUNDFOUNDFOUNDFOUNDFOUNDFOUNDFOUNDNULLFOUNDTRUEFOUNDFALSE 814FOUND FOUNDFOUNDFOUNDFOUND0�CDabcdFOUND\xXYZ abcdFOUND$$@#%^&*!~,.:;?:FOUND!!Hello,FOUNDWorldFOUND 815 FOUNDFOUNDFOUNDFOUND?Hello,FOUNDWorldFOUNDchr(0).chr(128).chr(234).chr(65).chr(255).chr(256)" 816-- search string has found '29' times 817 818--- Iteration 29 --- 819-- String after replacing the search value is => -- 820string(186) "Hello, world,0120333.3445-1.234567FOUNDNULL TRUE FALSE 821 0�CDabcd \xXYZ abcd $$@#%^&*!~,.:;?: !!Hello, World 822 ?Hello, World chr(0).chr(128).chr(234).chr(65).chr(255).chr(256)" 823-- search string has found '1' times 824 825--- Iteration 30 --- 826-- String after replacing the search value is => -- 827string(199) "Hello, world,0120333.3445-1.234567 NULL TRUE FALSE 828 0�CDaFOUNDcd \xXYZ aFOUNDcd $$@#%^&*!~,.:;?: !!Hello, World 829 ?Hello, World chr(0).chr(128).chr(234).chr(65).chr(255).chr(256)" 830-- search string has found '2' times 831 832--- Iteration 31 --- 833-- String after replacing the search value is => -- 834string(191) "Hello, world,0120333.3445-1.234567 NULL TRUE FALSE 835 0�CDabcd \xXYZ abcd $$@#%^&*!~,.:;?: !!Hello, World 836 ?Hello, World chr(0).chr(128).chr(234).chr(65).chr(255).chr(256)" 837-- search string has found '0' times 838 839--- Iteration 32 --- 840-- String after replacing the search value is => -- 841string(203) "Hello, world,0120333.3445-1.234567 NULL TRUE FALSE 842 FOUND 0�CDabcd \xXYZFOUNDabcd $$@#%^&*!~,.:;?: !!Hello, World 843FOUND ?Hello, World chr(0).chr(128).chr(234).chr(65).chr(255).chr(256)" 844-- search string has found '3' times 845 846--- Iteration 33 --- 847-- String after replacing the search value is => -- 848string(191) "Hello, world,0120333.3445-1.234567 NULL TRUE FALSE 849 0�CDabcd \xXYZ abcd $$@#%^&*!~,.:;?: !!Hello, World 850 ?Hello, World chr(0).chr(128).chr(234).chr(65).chr(255).chr(256)" 851-- search string has found '0' times 852 853--- Iteration 34 --- 854-- String after replacing the search value is => -- 855string(5) "FOUND" 856-- search string has found '1' times 857 858*** Testing Miscelleneous input data *** 859string(3) "qqq" 860int(5) 861array(3) { 862 [0]=> 863 string(3) "qqq" 864 [1]=> 865 string(0) "" 866 [2]=> 867 string(3) "ccc" 868} 869int(6) 870 871-- Testing objects -- 872string(12) "Hello, world" 873int(1) 874 875-- Testing arrays -- 876string(15) "multimultimulti" 877int(3) 878string(3) "qqq" 879int(3) 880array(2) { 881 [0]=> 882 string(3) "qqq" 883 [1]=> 884 string(3) "ccc" 885} 886int(6) 887 888Notice: Array to string conversion in %s on line %d 889array(2) { 890 [0]=> 891 string(15) "ArrayArrayArray" 892 [1]=> 893 string(3) "bbb" 894} 895int(3) 896array(2) { 897 [0]=> 898 string(3) "111" 899 [1]=> 900 string(3) "bbb" 901} 902int(3) 903array(2) { 904 [0]=> 905 string(4) "aaa3" 906 [1]=> 907 string(4) "2bbb" 908} 909int(1) 910 911-- Testing Resources -- 912string(%d) "Resource id #%d" 913int(0) 914string(%d) "Resource id #%d" 915int(0) 916 917-- Testing a longer and heredoc string -- 918string(623) "FOUNDghijklmnopqrstuvwxyz0123456789FOUNDghijklmnopqrstuvwxyz0123456789 919FOUNDghijklmnopqrstuvwxyz0123456789FOUNDghijklmnopqrstuvwxyz0123456789 920FOUNDghijklmnopqrstuvwxyz0123456789FOUNDghijklmnopqrstuvwxyz0123456789 921FOUNDghijklmnopqrstuvwxyz0123456789FOUNDghijklmnopqrstuvwxyz0123456789 922FOUNDghijklmnopqrstuvwxyz0123456789FOUNDghijklmnopqrstuvwxyz0123456789 923FOUNDghijklmnopqrstuvwxyz0123456789FOUNDghijklmnopqrstuvwxyz0123456789 924FOUNDghijklmnopqrstuvwxyz0123456789FOUNDghijklmnopqrstuvwxyz0123456789 925@#$%^&**&^%$#@!~:())))((((&&&**%$###@@@!!!~~~~@###$%^&* 926FOUNDghijklmnopqrstuvwxyz0123456789FOUNDghijklmnopqrstuvwxyz0123456789" 927int(16) 928 929-- Testing a heredoc null string -- 930string(0) "" 931int(0) 932 933-- Testing simple and complex syntax strings -- 934string(5) "FOUND" 935string(5) "FOUND" 936 937Notice: Undefined variable: strS in %s on line %d 938string(0) "" 939string(5) "FOUND" 940string(5) "FOUND" 941 942*** Testing error conditions *** 943Warning: str_replace() expects at least 3 parameters, 0 given in %s on line %d 944NULL 945 946Warning: str_replace() expects at least 3 parameters, 1 given in %s on line %d 947NULL 948 949Warning: str_replace() expects at least 3 parameters, 1 given in %s on line %d 950NULL 951 952Warning: str_replace() expects at least 3 parameters, 2 given in %s on line %d 953NULL 954 955Warning: str_replace() expects at most 4 parameters, 5 given in %s on line %d 956NULL 957Done 958