|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
[2009-02-19 19:16 UTC] kassah at gmail dot com
Description: ------------ http://us2.php.net/manual/en/language.oop5.autoload.php shows 'Note: Autoloading is not available if using PHP in CLI interactive mode' I made a simple test to check this, and it appears to be incorrect. If this is not an intended behavior, please let me know so that I can submit a bug to the ZendLoader documentation to include the same note. PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
|
|||||||||||||||||||||||||||
Copyright © 2001-2026 The PHP GroupAll rights reserved. |
Last updated: Tue Oct 06 20:00:02 2026 UTC |
Reproduction Process (and display): [root@nebula ~]$ php -a Interactive shell php > function __autoload($classname) { echo "boo!\n"; } php > boo::glah(); boo! PHP Fatal error: Class 'boo' not found in php shell code on line 1 [root@nebula ~]$No. The autoloader doesn't load classes when using -a. PHP 5.3.0beta2-dev (cli) (built: Feb 17 2009 09:48:08) Copyright (c) 1997-2009 The PHP Group Zend Engine v2.3.0, Copyright (c) 1998-2009 Zend Technologies ==== No php.ini (hides auto_prepend_file) and interactive mode C:>php -n -a Interactive mode enabled <?php echo ini_get('auto_prepend_file'); function __autoload($classname) { echo "No $classname", PHP_EOL;} echo static_Krypt::EnKryptB64('Richard'); ^Z Fatal error: Class 'static_Krypt' not found in C:\- on line 4 ==== Another example C:>php -n -a Interactive mode enabled <?php function __autoload($s) { echo $s;} boo::glah(); ^Z Fatal error: Class 'boo' not found in C:\- on line 1 ==== With php.ini (has an auto_prepend_file) and interactive mode C:>php -a Interactive mode enabled <?php echo ini_get('auto_prepend_file'); function __autoload($classname) { echo "No $classname", PHP_EOL;} echo static_Krypt::EnKryptB64('Richard'); ^Z auto_loader.php Fatal error: Cannot redeclare __autoload() (previously declared in D:\Data\PHP\Includes\auto_loader.php:18) in C:\- on line 2 ==== As above but with no local __autoload to Fatal error. C:>php -a Interactive mode enabled <?php echo ini_get('auto_prepend_file'); echo static_Krypt::EnKryptB64('Richard'); ^Z auto_loader.php Fatal error: Class 'static_Krypt' not found in C:\- on line 3 ==== Normal mode showing correct output and class accessed via autoloader. C:>php <?php echo ini_get('auto_prepend_file'); echo static_Krypt::EnKryptB64('Richard'); ^Z auto_loader.php gTcYaIFJOBA=