octdec_variation1.phpt 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164
  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. /* Prototype : number octdec ( string $octal_string )
  8. * Description: Returns the decimal equivalent of the octal number represented by the octal_string argument.
  9. * Source code: ext/standard/math.c
  10. */
  11. echo "*** Testing octdec() : usage variations ***\n";
  12. //get an unset variable
  13. $unset_var = 10;
  14. unset ($unset_var);
  15. // heredoc string
  16. $heredoc = <<<EOT
  17. abc
  18. xyz
  19. EOT;
  20. // get a resource variable
  21. $fp = fopen(__FILE__, "r");
  22. $inputs = array(
  23. // int data
  24. /*1*/ 0,
  25. 1,
  26. 12345,
  27. -2345,
  28. 4294967295, // largest decimal
  29. 4294967296,
  30. // float data
  31. /*7*/ 10.5,
  32. -10.5,
  33. 12.3456789000e10,
  34. 12.3456789000E-10,
  35. .5,
  36. // null data
  37. /*12*/ NULL,
  38. null,
  39. // boolean data
  40. /*14*/ true,
  41. false,
  42. TRUE,
  43. FALSE,
  44. // empty data
  45. /*18*/ "",
  46. '',
  47. array(),
  48. // string data
  49. /*21*/ "abcxyz",
  50. 'abcxyz',
  51. $heredoc,
  52. // undefined data
  53. /*24*/ @$undefined_var,
  54. // unset data
  55. /*25*/ @$unset_var,
  56. // resource variable
  57. /*26*/ $fp
  58. );
  59. // loop through each element of $inputs to check the behaviour of octdec()
  60. $iterator = 1;
  61. foreach($inputs as $input) {
  62. echo "\n-- Iteration $iterator --\n";
  63. var_dump(octdec($input));
  64. $iterator++;
  65. };
  66. fclose($fp);
  67. ?>
  68. ---Done---
  69. --EXPECTF--
  70. *** Testing octdec() : usage variations ***
  71. -- Iteration 1 --
  72. int(0)
  73. -- Iteration 2 --
  74. int(1)
  75. -- Iteration 3 --
  76. int(5349)
  77. -- Iteration 4 --
  78. int(1253)
  79. -- Iteration 5 --
  80. int(1134037)
  81. -- Iteration 6 --
  82. int(1134038)
  83. -- Iteration 7 --
  84. int(69)
  85. -- Iteration 8 --
  86. int(69)
  87. -- Iteration 9 --
  88. int(175304192)
  89. -- Iteration 10 --
  90. int(342391)
  91. -- Iteration 11 --
  92. int(5)
  93. -- Iteration 12 --
  94. int(0)
  95. -- Iteration 13 --
  96. int(0)
  97. -- Iteration 14 --
  98. int(1)
  99. -- Iteration 15 --
  100. int(0)
  101. -- Iteration 16 --
  102. int(1)
  103. -- Iteration 17 --
  104. int(0)
  105. -- Iteration 18 --
  106. int(0)
  107. -- Iteration 19 --
  108. int(0)
  109. -- Iteration 20 --
  110. Notice: Array to string conversion in %s on line %d
  111. int(0)
  112. -- Iteration 21 --
  113. int(0)
  114. -- Iteration 22 --
  115. int(0)
  116. -- Iteration 23 --
  117. int(0)
  118. -- Iteration 24 --
  119. int(0)
  120. -- Iteration 25 --
  121. int(0)
  122. -- Iteration 26 --
  123. int(%d)
  124. ---Done---