1--TEST--
2Test escapeshellarg() function : usage variations - different data types as $y arg
3--SKIPIF--
4<?php
5if( substr(PHP_OS, 0, 3) == "WIN" )
6  die("skip.. Do not run on Windows");
7?>
8--FILE--
9<?php
10
11/* Prototype  : string escapeshellarg  ( string $arg  )
12 * Description:  Escape a string to be used as a shell argument.
13 * Source code: ext/standard/exec.c
14 */
15
16echo "*** Testing escapeshellarg() : usage variations ***\n";
17
18//get an unset variable
19$unset_var = 10;
20unset ($unset_var);
21
22// heredoc string
23$heredoc = <<<EOT
24abc
25xyz
26EOT;
27
28
29// get a resource variable
30$fp = fopen(__FILE__, "r");
31
32$inputs = array(
33       // int data
34/*1*/  0,
35       1,
36       12,
37       -12,
38       2147483647,
39
40       // float data
41/*6*/  10.5,
42       -10.5,
43       1.234567e2,
44       1.234567E-2,
45       .5,
46
47       // null data
48/*11*/ NULL,
49       null,
50
51       // boolean data
52/*13*/ true,
53       false,
54       TRUE,
55       FALSE,
56
57       // empty data
58/*17*/ "",
59       '',
60
61       // undefined data
62/*19*/ @$undefined_var,
63
64       // unset data
65/*20*/ @$unset_var,
66
67);
68
69// loop through each element of $inputs to check the behaviour of escapeshellarg()
70$iterator = 1;
71foreach($inputs as $input) {
72	echo "\n-- Iteration $iterator --\n";
73	var_dump(escapeshellarg($input));
74	$iterator++;
75};
76?>
77===Done===
78--EXPECT--
79*** Testing escapeshellarg() : usage variations ***
80
81-- Iteration 1 --
82string(3) "'0'"
83
84-- Iteration 2 --
85string(3) "'1'"
86
87-- Iteration 3 --
88string(4) "'12'"
89
90-- Iteration 4 --
91string(5) "'-12'"
92
93-- Iteration 5 --
94string(12) "'2147483647'"
95
96-- Iteration 6 --
97string(6) "'10.5'"
98
99-- Iteration 7 --
100string(7) "'-10.5'"
101
102-- Iteration 8 --
103string(10) "'123.4567'"
104
105-- Iteration 9 --
106string(12) "'0.01234567'"
107
108-- Iteration 10 --
109string(5) "'0.5'"
110
111-- Iteration 11 --
112string(2) "''"
113
114-- Iteration 12 --
115string(2) "''"
116
117-- Iteration 13 --
118string(3) "'1'"
119
120-- Iteration 14 --
121string(2) "''"
122
123-- Iteration 15 --
124string(3) "'1'"
125
126-- Iteration 16 --
127string(2) "''"
128
129-- Iteration 17 --
130string(2) "''"
131
132-- Iteration 18 --
133string(2) "''"
134
135-- Iteration 19 --
136string(2) "''"
137
138-- Iteration 20 --
139string(2) "''"
140===Done===
141