1--TEST-- 2Test escapeshellarg() function : usage variations - different data types as $arg arg 3--SKIPIF-- 4<?php 5if( substr(PHP_OS, 0, 3) != "WIN" ) 6 die("skip.. only for 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 50// loop through each element of $inputs to check the behaviour of escapeshellarg() 51$iterator = 1; 52foreach($inputs as $input) { 53 echo "\n-- Iteration $iterator --\n"; 54 var_dump(escapeshellarg($input)); 55 $iterator++; 56}; 57?> 58--EXPECT-- 59*** Testing escapeshellarg() : usage variations *** 60 61-- Iteration 1 -- 62string(3) ""0"" 63 64-- Iteration 2 -- 65string(3) ""1"" 66 67-- Iteration 3 -- 68string(4) ""12"" 69 70-- Iteration 4 -- 71string(5) ""-12"" 72 73-- Iteration 5 -- 74string(12) ""2147483647"" 75 76-- Iteration 6 -- 77string(6) ""10.5"" 78 79-- Iteration 7 -- 80string(7) ""-10.5"" 81 82-- Iteration 8 -- 83string(10) ""123.4567"" 84 85-- Iteration 9 -- 86string(12) ""0.01234567"" 87 88-- Iteration 10 -- 89string(5) ""0.5"" 90 91-- Iteration 11 -- 92string(3) ""1"" 93 94-- Iteration 12 -- 95string(2) """" 96 97-- Iteration 13 -- 98string(3) ""1"" 99 100-- Iteration 14 -- 101string(2) """" 102 103-- Iteration 15 -- 104string(2) """" 105 106-- Iteration 16 -- 107string(2) """" 108