Welcome! » Log In » Create A New Profile

spl_autoload_register not orking for me

Posted by Nickx 
Nickx
spl_autoload_register not orking for me
August 10, 2018 11:13AM

Hi there

Trying to incorporate the latest version of html purifier into our system. I hae stripped back to a simple autoloader and the following script throws a fatal error:

spl_autoload_register(function ($className) {
    $dir = $_SERVER['DOCUMENT_ROOT'];
	if($className == 'HTMLPurifier'){
		require_once($dir . '/includes/htmlpurifier/library/HTMLPurifier.auto.php');
	}
});
$purifier = new HTMLPurifier();

The file is being required just fine but we get:

Fatal error: Class 'HTMLPurifier' not found in .../hptest.php on line 9
Nickx
Re: spl_autoload_register not orking for me
August 10, 2018 11:16AM

forgot to mention - running php 5.6.37

Nickx
Re: spl_autoload_register not orking for me
August 10, 2018 11:31AM

ok think i'm being thick, the html purifier 'HTMLPurifier.auto.php' file is its own autoloader and just needs to be plonked in as an include outside the system's own spl for classes ?

Re: spl_autoload_register not orking for me
August 26, 2018 01:31AM

Yep, that's right. Include that file (somehow) and it will all get setup.

Sorry, you do not have permission to post/reply in this forum.