strval_basic.phpt 1.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970
  1. --TEST--
  2. Test strval() function : basic functionality
  3. --FILE--
  4. <?php
  5. echo "*** Testing strval() : basic variations ***\n";
  6. error_reporting(E_ALL ^ E_NOTICE);
  7. $simple_heredoc =<<<EOT
  8. Simple HEREDOC string
  9. EOT;
  10. //array of values to iterate over
  11. $values = array(
  12. // Simple strings
  13. /*1*/ "Hello World",
  14. 'Hello World',
  15. // String with control chars
  16. /*3*/ "String\nwith\ncontrol\ncharacters\r\n",
  17. // String with quotes
  18. /*4*/ "String with \"quotes\"",
  19. //Numeric String
  20. /*5*/ "123456",
  21. // Hexadecimal string
  22. /*6*/ "0xABC",
  23. //Heredoc String
  24. /*7*/ $simple_heredoc
  25. );
  26. // loop through each element of the array for strval
  27. $iterator = 1;
  28. foreach($values as $value) {
  29. echo "\n-- Iteration $iterator --\n";
  30. var_dump( strval($value) );
  31. $iterator++;
  32. };
  33. ?>
  34. --EXPECT--
  35. *** Testing strval() : basic variations ***
  36. -- Iteration 1 --
  37. string(11) "Hello World"
  38. -- Iteration 2 --
  39. string(11) "Hello World"
  40. -- Iteration 3 --
  41. string(32) "String
  42. with
  43. control
  44. characters
  45. "
  46. -- Iteration 4 --
  47. string(20) "String with "quotes""
  48. -- Iteration 5 --
  49. string(6) "123456"
  50. -- Iteration 6 --
  51. string(5) "0xABC"
  52. -- Iteration 7 --
  53. string(21) "Simple HEREDOC string"