octdec_variation1.phpt 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158
  1. --TEST--
  2. Test octdec() function : usage variations - different data types as $octal_string arg
  3. --INI--
  4. precision=14
  5. --FILE--
  6. <?php
  7. echo "*** Testing octdec() : usage variations ***\n";
  8. // heredoc string
  9. $heredoc = <<<EOT
  10. abc
  11. xyz
  12. EOT;
  13. // get a resource variable
  14. $fp = fopen(__FILE__, "r");
  15. $inputs = array(
  16. // int data
  17. /*1*/ 0,
  18. 1,
  19. 12345,
  20. -2345,
  21. 4294967295, // largest decimal
  22. 4294967296,
  23. // float data
  24. /*7*/ 10.5,
  25. -10.5,
  26. 12.3456789000e10,
  27. 12.3456789000E-10,
  28. .5,
  29. // boolean data
  30. /*14*/ true,
  31. false,
  32. TRUE,
  33. FALSE,
  34. // empty data
  35. /*18*/ "",
  36. '',
  37. array(),
  38. // string data
  39. /*21*/ "abcxyz",
  40. 'abcxyz',
  41. $heredoc,
  42. // resource variable
  43. /*26*/ $fp
  44. );
  45. // loop through each element of $inputs to check the behaviour of octdec()
  46. $iterator = 1;
  47. foreach($inputs as $input) {
  48. echo "\n-- Iteration $iterator --\n";
  49. try {
  50. var_dump(octdec($input));
  51. } catch (TypeError $e) {
  52. echo $e->getMessage(), "\n";
  53. }
  54. $iterator++;
  55. };
  56. fclose($fp);
  57. ?>
  58. ---Done---
  59. --EXPECTF--
  60. *** Testing octdec() : usage variations ***
  61. -- Iteration 1 --
  62. int(0)
  63. -- Iteration 2 --
  64. int(1)
  65. -- Iteration 3 --
  66. int(5349)
  67. -- Iteration 4 --
  68. Deprecated: Invalid characters passed for attempted conversion, these have been ignored in %s on line %d
  69. int(1253)
  70. -- Iteration 5 --
  71. Deprecated: Invalid characters passed for attempted conversion, these have been ignored in %s on line %d
  72. int(1134037)
  73. -- Iteration 6 --
  74. Deprecated: Invalid characters passed for attempted conversion, these have been ignored in %s on line %d
  75. int(1134038)
  76. -- Iteration 7 --
  77. Deprecated: Invalid characters passed for attempted conversion, these have been ignored in %s on line %d
  78. int(69)
  79. -- Iteration 8 --
  80. Deprecated: Invalid characters passed for attempted conversion, these have been ignored in %s on line %d
  81. int(69)
  82. -- Iteration 9 --
  83. Deprecated: Invalid characters passed for attempted conversion, these have been ignored in %s on line %d
  84. int(175304192)
  85. -- Iteration 10 --
  86. Deprecated: Invalid characters passed for attempted conversion, these have been ignored in %s on line %d
  87. int(342391)
  88. -- Iteration 11 --
  89. Deprecated: Invalid characters passed for attempted conversion, these have been ignored in %s on line %d
  90. int(5)
  91. -- Iteration 12 --
  92. int(1)
  93. -- Iteration 13 --
  94. int(0)
  95. -- Iteration 14 --
  96. int(1)
  97. -- Iteration 15 --
  98. int(0)
  99. -- Iteration 16 --
  100. int(0)
  101. -- Iteration 17 --
  102. int(0)
  103. -- Iteration 18 --
  104. octdec(): Argument #1 ($octal_string) must be of type string, array given
  105. -- Iteration 19 --
  106. Deprecated: Invalid characters passed for attempted conversion, these have been ignored in %s on line %d
  107. int(0)
  108. -- Iteration 20 --
  109. Deprecated: Invalid characters passed for attempted conversion, these have been ignored in %s on line %d
  110. int(0)
  111. -- Iteration 21 --
  112. Deprecated: Invalid characters passed for attempted conversion, these have been ignored in %s on line %d
  113. int(0)
  114. -- Iteration 22 --
  115. octdec(): Argument #1 ($octal_string) must be of type string, resource given
  116. ---Done---