2 /* Prototype : bool interface_exists(string classname [, bool autoload])
3 * Description: Checks if the class exists
4 * Source code: Zend/zend_builtin_functions.c
8 echo "*** Testing interface_exists() : usage variation ***\n";
10 // Initialise function arguments not being substituted (if any)
13 //get an unset variable
17 // define some classes
18 class classWithToString
20 public function __toString() {
21 return "Class A object";
25 class classWithoutToString
35 $index_array = array (1, 2, 3);
36 $assoc_array = array ('one' => 1, 'two' => 2);
38 //array of values to iterate over
45 'int -12345' => -2345,
49 'float -10.5' => -10.5,
50 'float 12.3456789000e10' => 12.3456789000e10
,
51 'float -12.3456789000e10' => -12.3456789000e10
,
55 'empty array' => array(),
56 'int indexed array' => $index_array,
57 'associative array' => $assoc_array,
58 'nested arrays' => array('foo', $index_array, $assoc_array),
61 'uppercase NULL' => NULL,
62 'lowercase null' => null,
65 'lowercase true' => true,
66 'lowercase false' =>false,
67 'uppercase TRUE' =>TRUE,
68 'uppercase FALSE' =>FALSE,
71 'empty string DQ' => "",
72 'empty string SQ' => '',
75 'instance of classWithToString' => new classWithToString(),
76 'instance of classWithoutToString' => new classWithoutToString(),
79 'undefined var' => @$undefined_var,
82 'unset var' => @$unset_var,
85 // loop through each element of the array for classname
87 foreach($inputs as $key =>$value) {
89 var_dump( interface_exists($value, $autoload) );