import zend standard tests
[hiphop-php.git] / hphp / test / zend / bad / ext-standard-strings / strspn_variation2.php
blobc63565b7a46ab80fad5b29f2618b18be6cd5f6a8
1 <?php
2 /* Prototype : proto int strspn(string str, string mask [, int start [, int len]])
3 * Description: Finds length of initial segment consisting entirely of characters found in mask.
4 If start or/and length is provided works like strspn(substr($s,$start,$len),$good_chars)
5 * Source code: ext/standard/string.c
6 * Alias to functions: none
7 */
9 error_reporting(E_ALL & ~E_NOTICE);
12 * Testing strspn() : with different unexpected values for mask argument
15 echo "*** Testing strspn() : with diferent unexpected values of mask argument ***\n";
17 $str = 'string_val';
18 $start = 1;
19 $len = 10;
22 //get an unset variable
23 $unset_var = 10;
24 unset ($unset_var);
26 // declaring class
27 class sample {
28 public function __toString() {
29 return "object";
33 // creating a file resource
34 $file_handle = fopen(__FILE__, 'r');
37 //array of values to iterate over
38 $values = array(
40 // int data
43 12345,
44 -2345,
46 // float data
47 10.5,
48 -10.5,
49 10.1234567e10,
50 10.7654321E-10,
51 .5,
53 // array data
54 array(),
55 array(0),
56 array(1),
57 array(1, 2),
58 array('color' => 'red', 'item' => 'pen'),
60 // null data
61 NULL,
62 null,
64 // boolean data
65 true,
66 false,
67 TRUE,
68 FALSE,
70 // empty data
71 "",
72 '',
74 // object data
75 new sample(),
77 // undefined data
78 $undefined_var,
80 // unset data
81 $unset_var,
83 // resource
84 $file_handle
87 // loop through each element of the array for mask
89 foreach($values as $value) {
90 echo "\n-- Iteration with mask value as \"$value\" --\n";
91 var_dump( strspn($str,$value) ); // with defalut args
92 var_dump( strspn($str,$value,$start) ); // with default len value
93 var_dump( strspn($str,$value,$start,$len) ); // with all args
96 // close the resource
97 fclose($file_handle);
99 echo "Done"