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