import zend standard tests
[hiphop-php.git] / hphp / test / zend / bad / ext-standard-strings / strspn_variation3.php
blob6cd66e4e2ec1ac2db93beae8be6e6ac91532ce11
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 unexpected values of start argument
15 echo "*** Testing strspn() : with unexpected values of start argument ***\n";
17 // initialing required variables
18 $str = 'string_val';
19 $mask = 'soibtFTf1234567890';
20 $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 // float data
41 10.5,
42 -10.5,
43 10.1234567e8,
44 10.7654321E-8,
45 .5,
47 // array data
48 array(),
49 array(0),
50 array(1),
51 array(1, 2),
52 array('color' => 'red', 'item' => 'pen'),
54 // null data
55 NULL,
56 null,
58 // boolean data
59 true,
60 false,
61 TRUE,
62 FALSE,
64 // empty data
65 "",
66 '',
68 // string data
69 "string",
70 'string',
72 // object data
73 new sample(),
75 // undefined data
76 $undefined_var,
78 // unset data
79 $unset_var,
81 // resource
82 $file_handle
85 // loop through each element of the array for start
87 foreach($values as $value) {
88 echo "\n-- Iteration with start value as \"$value\" --\n";
89 var_dump( strspn($str,$mask,$value) ); // with default len value
90 var_dump( strspn($str,$mask,$value,$len) ); // with all args
93 // closing the resource
94 fclose($file_handle);
96 echo "Done"