Arnsenal Posted March 9, 2012 Share Posted March 9, 2012 Im trying to use the HTMLPurifier's class's functions inside my class by extending my class from it. http://htmlpurifier.org/ Here is what I get for an error. Warning: Passing a prototype to HTMLPurifier_Lexer::create() is deprecated, please instead use %Core.LexerImpl in C:\Users\Jerry\Desktop\Web Dev\Local Host - Web Dev\PHPTester\library\HTMLPurifier\Lexer.php on line 74 Fatal error: Call to a member function get() on a non-object in C:\Users\Jerry\Desktop\Web Dev\Local Host - Web Dev\PHPTester\library\HTMLPurifier\Lexer.php on line 80 Having a very hard time even seeking information, my knowledge of php is too limited to begin to know where to look. Do I need to provide more information? Thanks Jerry Quote Link to comment https://forums.phpfreaks.com/topic/258564-error-when-extending-html-purifier-class/ Share on other sites More sharing options...
trq Posted March 9, 2012 Share Posted March 9, 2012 Do I need to provide more information? Some code would be useful. Though these errors look like they are generated by HTMLPurifier itself. Quote Link to comment https://forums.phpfreaks.com/topic/258564-error-when-extending-html-purifier-class/#findComment-1325418 Share on other sites More sharing options...
Arnsenal Posted March 10, 2012 Author Share Posted March 10, 2012 Thanks Thorpe Yes the error is generated by Lexer.php which I attached. Here is my class code that is giving me the errors. require_once '/library/HTMLPurifier.auto.php'; $db_info = array ('host','user_name','password','db','table'); $purifier = new HTMLPurifier(); class s_v extends HTMLPurifier { public $clean_array; public $empty_fields_array = array(); public $invalid_fields_array = array(); private $db_info; public function __construct($dirty_array,$db_info) { foreach ($dirty_array as $key => $value) { $value = $this->purify($value); } $this->clean_array=$dirty_array; $this->db_info = $db_info; echo "'$this->db_info[0]'"."'$this->db_info[1]'"."'$this->db_info[2]'"."'$this->db_info[3]'"; } } $sv = new s_v($req_post_array,$db_info); There are notes in the lexer.php file. Thanks again. It would be awesome if you pointed me in the right direction even if you don't have time to help working out the solution. 17751_.php Quote Link to comment https://forums.phpfreaks.com/topic/258564-error-when-extending-html-purifier-class/#findComment-1325876 Share on other sites More sharing options...
Arnsenal Posted March 10, 2012 Author Share Posted March 10, 2012 Ok I may be on to something. http://us3.php.net/manual/en/language.oop5.paamayim-nekudotayim.php A couple questions 1. Am I suppose to be using :: to access functions from the class I'm extending? 2. If I'm extending a class that has a constructor and I create another constructor in my extended class then instantiate the extended class do both constructors run, or does one have precedence? Thanks Jerry Quote Link to comment https://forums.phpfreaks.com/topic/258564-error-when-extending-html-purifier-class/#findComment-1325913 Share on other sites More sharing options...
trq Posted March 10, 2012 Share Posted March 10, 2012 1) If the methods are declared as static 2) No, you need to explicitly call the parent __construct within your classes's __construct and pass through any required params. eg; public function __construct($foo) { parent::__construct($foo); } Quote Link to comment https://forums.phpfreaks.com/topic/258564-error-when-extending-html-purifier-class/#findComment-1326004 Share on other sites More sharing options...
Arnsenal Posted April 1, 2012 Author Share Posted April 1, 2012 Thorpe, Thank You All I needed to do was instantiate the parent constructor within my subclass constructor and all was fine. Thanks Again. Quote Link to comment https://forums.phpfreaks.com/topic/258564-error-when-extending-html-purifier-class/#findComment-1333331 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.