#47452 [Opn]: Autoloader is marked as not working in CLI when it is.

From: Date: Fri, 20 Feb 2009 11:11:26 +0000
Subject: #47452 [Opn]: Autoloader is marked as not working in CLI when it is.
References: 1  Groups: php.doc.bugs 
Request: Send a blank email to doc-bugs+get-1907@lists.php.net to get a copy of this message
ID: 47452 Updated by: rquadling@php.net Reported By: kassah at gmail dot com Status: Open Bug Type: Documentation problem Operating System: Ubuntu 8.10 Linux PHP Version: Irrelevant New Comment: 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= Previous Comments: ------------------------------------------------------------------------ [2009-02-20 03:27:42] kassah at gmail dot com 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 ~]$ ------------------------------------------------------------------------ [2009-02-20 03:21:57] kassah at gmail dot com http://us2.php.net/manual/en/features.commandline.php Also mentions it in Command line options -a. ------------------------------------------------------------------------ [2009-02-19 19:16:08] 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. ------------------------------------------------------------------------ -- Edit this bug report at http://bugs.php.net/?id=47452&edit=1

« previous php.doc.bugs (#1907) next »