strval_basic.phpt 1.3 KB

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