str_replace.phpt 23 KB

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