Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

PHP: __autoload function doesn't ever called

So, I have xampp. I tested this code on ZendServer, result the same.

<?php
error_reporting(E_ALL);

define ("ABS_PATH", 'C:\xampp\htdocs\oopHotLine\\');

function __autoload($class_name) {
    echo 'gg';
    require_once (ABS_PATH.'classes\\'.$class_name.'.php');
}

$process=new Main('1');
?>

after php.exe -a index.php i have this:

Interactive mode enabled
Fatal error: Class 'Main' not found in C:\xampp\htdocs\oopHotLine\index.php on line 10
[Finished]

so, it doesn shows 'gg' output. If i manually do __autoload('Main'); - all OK. The same for the manual require_once or include. All permissions in windows folder set to full access. Php version - PHP Version => 5.3.8;

Please, help.

like image 797
NiPh Avatar asked Sep 10 '26 23:09

NiPh


1 Answers

As DaveRandom pointed:

Autoloading is not available if using PHP in CLI interactive mode.

So, instead of using php.exe -a index.php, cut the -a off and try running the script with php.exe index.php instead.

like image 51
J. Bruni Avatar answered Sep 12 '26 12:09

J. Bruni



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!