php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Doc Bug #47452 Autoloader is marked as not working in CLI when it is.
Submitted: 2009-02-19 19:16 UTC Modified: 2009-02-20 11:28 UTC
From: kassah at gmail dot com Assigned:
Status: Not a bug Package: Documentation problem
PHP Version: Irrelevant OS: Ubuntu 8.10 Linux
Private report: No CVE-ID: None
Welcome back! If you're the original bug submitter, here's where you can edit the bug or add additional notes.
If you forgot your password, you can retrieve your password here.
Password:
Status:
Package:
Bug Type:
Summary:
From: kassah at gmail dot com
New email:
PHP Version: OS:

 

 [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.


Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2009-02-20 03:21 UTC] kassah at gmail dot com
http://us2.php.net/manual/en/features.commandline.php
Also mentions it in Command line options -a.
 [2009-02-20 03:27 UTC] 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 11:11 UTC] rquadling@php.net
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=



 [2009-02-20 11:28 UTC] rquadling@php.net
Autoloading of classes does not occur when using PHP in interactive 
mode.
 
PHP Copyright © 2001-2025 The PHP Group
All rights reserved.
Last updated: Thu Jul 17 00:01:31 2025 UTC