Title: How to fix class ct_fields { function ct_fields() } for PHP 7
Last modified: April 27, 2017

---

# How to fix class ct_fields { function ct_fields() } for PHP 7

 *  [niska](https://wordpress.org/support/users/niska/)
 * (@niska)
 * [9 years, 1 month ago](https://wordpress.org/support/topic/how-to-fix-class-ct_fields-function-ct_fields/)
 * 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 9 years, 1 month ago by [niska](https://wordpress.org/support/users/niska/).
    -  This topic was modified 9 years, 1 month ago by [niska](https://wordpress.org/support/users/niska/).

Viewing 1 replies (of 1 total)

 *  [Juliette Reinders Folmer](https://wordpress.org/support/users/jrf/)
 * (@jrf)
 * [9 years, 1 month ago](https://wordpress.org/support/topic/how-to-fix-class-ct_fields-function-ct_fields/#post-9074086)
 * 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.

 * ![](https://ps.w.org/php-compatibility-checker/assets/icon-256x256.png?rev=1446087)
 * [PHP Compatibility Checker](https://wordpress.org/plugins/php-compatibility-checker/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/php-compatibility-checker/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/php-compatibility-checker/)
 * [Active Topics](https://wordpress.org/support/plugin/php-compatibility-checker/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/php-compatibility-checker/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/php-compatibility-checker/reviews/)

## Tags

 * [deprecated](https://wordpress.org/support/topic-tag/deprecated/)
 * [php-7](https://wordpress.org/support/topic-tag/php-7/)

 * 1 reply
 * 2 participants
 * Last reply from: [Juliette Reinders Folmer](https://wordpress.org/support/users/jrf/)
 * Last activity: [9 years, 1 month ago](https://wordpress.org/support/topic/how-to-fix-class-ct_fields-function-ct_fields/#post-9074086)
 * Status: not resolved