Class const to $variable

4016 views php
-3

I have this code:

class ContactIntegration {

  const P_DESCRIPTION = 'description here';
  const MAIL_SENT_TRIGGER = '7_mail_sent';

  public $form_data;

  public $default_payload = array(

      'form_origem' => self::P_DESCRIPTION
  );

I need to change const P_DESCRIPTION = 'description here'; to const P_DESCRIPTION = $variable; or 'form_origem' => self::P_DESCRIPTION to 'form_origem' => $variable;.

answered question

1 Answer

12

I hope, this is what you want.

class ContactIntegration {

  public static $variable= 'Any variable';
  const MAIL_SENT_TRIGGER = '7_mail_sent';

  public $form_data;

  public $default_payload = array(

      'form_origem' => self::$variable
  );

posted this

Have an answer?

JD

Please login first before posting an answer.