import zend standard tests
[hiphop-php.git] / hphp / test / zend / bad / ext-standard-strings / str_pad_variation1.php
blob604baacf895a7ea1d74fdbab1f545aa281f1eee1
1 <?php
2 /* Prototype : string str_pad ( string $input , int $pad_length [, string $pad_string [, int $pad_type ]] )
3 * Description: Pad a string to a certain length with another string
4 * Source code: ext/standard/string.c
5 */
7 /* Test str_pad() function: with unexpected inputs for '$input'
8 * and expected type for '$pad_length'
9 */
11 echo "*** Testing str_pad() function: with unexpected inputs for 'input' argument ***\n";
13 //get an unset variable
14 $unset_var = 'string_val';
15 unset($unset_var);
17 //defining a class
18 class sample {
19 public function __toString() {
20 return "sample object";
24 //getting the resource
25 $file_handle = fopen(__FILE__, "r");
27 // array with different values for $input
28 $inputs = array (
30 // integer values
31 /*1*/ 0,
33 -2,
34 2147483647,
35 -2147483648,
37 // float values
38 /*6*/ 10.5,
39 -20.5,
40 10.1234567e10,
42 // array values
43 /*9*/ array(),
44 array(0),
45 array(1, 2),
47 // boolean values
48 /*12*/ true,
49 false,
50 TRUE,
51 FALSE,
53 // null vlaues
54 /*16*/ NULL,
55 null,
57 // objects
58 /*18*/ new sample(),
60 // resource
61 /*19*/ $file_handle,
63 // undefined variable
64 /*20*/ @$undefined_var,
66 // unset variable
67 /*21*/ @$unset_var
70 //defining '$pad_length' argument
71 $pad_length = "20";
73 // loop through with each element of the $inputs array to test str_pad() function
74 $count = 1;
75 foreach($inputs as $input) {
76 echo "-- Iteration $count --\n";
77 var_dump( str_pad($input, $pad_length) );
78 $count ++;
81 fclose($file_handle); //closing the file handle
84 ===DONE===