• I get this message: “Use of deprecated PHP4 style class constructor is not supported since PHP 7”

    How can I fix this? This is the code:

    if ( !class_exists( 'ct_fields' ) ) :
    class ct_fields
    {
    	var $ct_type;
    	var $ct_field_name;
    	var $ct_field_label;
    	var $ct_field_type ;
    	var $ct_field_desc ;
    	var $ct_field_val ;
    	function ct_fields($taxonomy,$name,$label,$type,$desc,$val)
    	{
    • This topic was modified 7 years, 11 months ago by niska.
    • This topic was modified 7 years, 11 months ago by niska.
Viewing 1 replies (of 1 total)
  • You’ll need to rename the ct_fields method to __construct and add a fall-back ct_fields method which calls __construct just in case any child classes use the original method or in case it’s called from elsewhere.

    So your class will look something like:

    class ct_fields
    {
    	var $ct_type;
    	var $ct_field_name;
    	var $ct_field_label;
    	var $ct_field_type ;
    	var $ct_field_desc ;
    	var $ct_field_val ;
    	function __construct($taxonomy,$name,$label,$type,$desc,$val)
    	{
    		// The code you originally had in the <code>ct_fields</code> method
    	}
    
    	function ct_fields($taxonomy,$name,$label,$type,$desc,$val)
    	{
    		self::__construct($taxonomy,$name,$label,$type,$desc,$val);
    	}
    
Viewing 1 replies (of 1 total)
  • The topic ‘How to fix class ct_fields { function ct_fields() } for PHP 7’ is closed to new replies.