1--TEST-- 2Test class_exists() function : basic functionality 3--FILE-- 4<?php 5/* Prototype : proto bool class_exists(string classname [, bool autoload]) 6 * Description: Checks if the class exists 7 * Source code: Zend/zend_builtin_functions.c 8 * Alias to functions: 9 */ 10 11echo "*** Testing class_exists() : basic functionality ***\n"; 12 13spl_autoload_register(function ($className) { 14 echo "In autoload($className)\n"; 15}); 16 17echo "Calling class_exists() on non-existent class with autoload explicitly enabled:\n"; 18var_dump( class_exists('C', true) ); 19echo "\nCalling class_exists() on existing class with autoload explicitly enabled:\n"; 20var_dump( class_exists('stdclass', true) ); 21 22echo "\nCalling class_exists() on non-existent class with autoload explicitly enabled:\n"; 23var_dump( class_exists('D', false) ); 24echo "\nCalling class_exists() on existing class with autoload explicitly disabled:\n"; 25var_dump( class_exists('stdclass', false) ); 26 27echo "\nCalling class_exists() on non-existent class with autoload unspecified:\n"; 28var_dump( class_exists('E') ); 29echo "\nCalling class_exists() on existing class with autoload unspecified:\n"; 30var_dump( class_exists('stdclass') ); 31 32echo "Done"; 33?> 34--EXPECTF-- 35*** Testing class_exists() : basic functionality *** 36Calling class_exists() on non-existent class with autoload explicitly enabled: 37In autoload(C) 38bool(false) 39 40Calling class_exists() on existing class with autoload explicitly enabled: 41bool(true) 42 43Calling class_exists() on non-existent class with autoload explicitly enabled: 44bool(false) 45 46Calling class_exists() on existing class with autoload explicitly disabled: 47bool(true) 48 49Calling class_exists() on non-existent class with autoload unspecified: 50In autoload(E) 51bool(false) 52 53Calling class_exists() on existing class with autoload unspecified: 54bool(true) 55Done 56