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 11echo "*** Testing escapeshellarg() : usage variations ***\n"; 12 13// heredoc string 14$heredoc = <<<EOT 15abc 16xyz 17EOT; 18 19 20// get a resource variable 21$fp = fopen(__FILE__, "r"); 22 23$inputs = array( 24 // int data 25/*1*/ 0, 26 1, 27 12, 28 -12, 29 2147483647, 30 31 // float data 32/*6*/ 10.5, 33 -10.5, 34 1.234567e2, 35 1.234567E-2, 36 .5, 37 38 // boolean data 39/*13*/ true, 40 false, 41 TRUE, 42 FALSE, 43 44 // empty data 45/*17*/ "", 46 '', 47); 48 49// loop through each element of $inputs to check the behaviour of escapeshellarg() 50$iterator = 1; 51foreach($inputs as $input) { 52 echo "\n-- Iteration $iterator --\n"; 53 var_dump(escapeshellarg($input)); 54 $iterator++; 55}; 56?> 57--EXPECT-- 58*** Testing escapeshellarg() : usage variations *** 59 60-- Iteration 1 -- 61string(3) "'0'" 62 63-- Iteration 2 -- 64string(3) "'1'" 65 66-- Iteration 3 -- 67string(4) "'12'" 68 69-- Iteration 4 -- 70string(5) "'-12'" 71 72-- Iteration 5 -- 73string(12) "'2147483647'" 74 75-- Iteration 6 -- 76string(6) "'10.5'" 77 78-- Iteration 7 -- 79string(7) "'-10.5'" 80 81-- Iteration 8 -- 82string(10) "'123.4567'" 83 84-- Iteration 9 -- 85string(12) "'0.01234567'" 86 87-- Iteration 10 -- 88string(5) "'0.5'" 89 90-- Iteration 11 -- 91string(3) "'1'" 92 93-- Iteration 12 -- 94string(2) "''" 95 96-- Iteration 13 -- 97string(3) "'1'" 98 99-- Iteration 14 -- 100string(2) "''" 101 102-- Iteration 15 -- 103string(2) "''" 104 105-- Iteration 16 -- 106string(2) "''" 107