__autoload() no workie on my 5.2 install...
| From: | Nathan Hawks | Date: | Mon, 12 Mar 2007 05:55:26 +0000 |
| Subject: | __autoload() no workie on my 5.2 install... | ||
| Groups: | php.general | ||
| Request: | Send a blank email to php-general+get-250268@lists.php.net to get a copy of this message | ||
Hey all. This is my first post, 'coz it's the first time I've ever had
such a confusing problem with PHP.
I recently got a VPS and compiled PHP 5.2.1 with the following options:
--prefix=/usr/local/php5 --with-apxs2=/usr/local/apache2/bin/apxs
--with-config-file-path=/etc/php5 --with-curl
--with-curl-dir=/usr/local/lib --with-gd --with-gd-dir=/usr/local
--with-gettext --with-jpeg-dir=/usr/local/lib --with-kerberos
--with-mcrypt --with-mhash --with-mysql=/usr --with-pear
--with-png-dir=/usr/local/lib --with-xml --with-zlib
--with-zlib-dir=/usr/local/lib --with-zip --with-openssl --enable-bcmath
--enable-calendar --enable-ftp --enable-magic-quotes --enable-sockets
--enable-track-vars --enable-mbstring --enable-memory-limit
--with-freetype-dir=/usr/include/freetype2 --enable-soap
--with-mysql-sock=/tmp/mysql.sock
Apache is 2.2.4 and was also hand-compiled.
Meanwhile, at home, I have PHP 5.1.6 and Apache 2.2.3.
At home, __autoload() works great.
On the VPS, it doesn't work at all.
Here is a small case:
= - = - = - = - = - = - = - = - = - = - = - = - = - = - = - = - =
test.php:
<?php
function __autoload($classname) {
include_once(dirname(__FILE__) . "/$classname.php");
}
$thinger = new foo();
echo $thinger->boo;
?>
= - = - = - = - = - = - = - = - = - = - = - = - = - = - = - = - =
foo.php:
<?php
class foo {
var $boo;
function foo() {
$this->boo = "I wouldn't say 'boo' if this autoloader worked on my
server...\n";
}
}
?>
= - = - = - = - = - = - = - = - = - = - = - = - = - = - = - = - =
And, the crying begins:
[nhawks@www ~]$ php test.php
Fatal error: Cannot instantiate non-existent class: foo
in /home/nhawks/test.php on line 5
Naturally for this simple test case, both files are in the same
directory.
When I do the same thing at home...
[nhawks@skami ~]$ php test.php
I wouldn't say 'boo' if this autoloader worked on my server...
I don't understand why __autoload() would fail, I didn't explicitly
enable it when compiling at home and I can't find anything via Google to
help ...
No clues whatsoever in my Apache error_log. When I try throwing:
echo("Got here!\n");
..into my __autoload() function, it reveals that __autoload() is never
being fired.
Please help.
Nathan