I have a problem with the PHP file that I am using and I cannot find a solution.
In one part of the code, the value for $this->value , and the value is set correctly in accordance with my testing.
However, later in the same code $this->value empty.
Here is the code:
<?php class Padd_Input_Advertisement { protected $keyword; protected $value; protected $name; protected $description; function __construct($keyword,$name,$description='') { $this->keyword = $keyword; $this->value = unserialize(get_option($keyword)); $this->name = $name; $this->description = $description; } public function get_keyword() { return $this->keyword; } public function set_keyword($keyword) { $this->keyword = $keyword; } public function get_value() { return $this->value; } public function set_value($value) { $this->value = $value; } public function get_name() { return $this->name; } public function set_name($name) { $this->name = $name; } public function get_description() { return $this->description; } public function set_description($description) { $this->description = $description; } public function __toString() { $strHTML = ''; $strHTML .= '<tr valign="top">'; $strHTML .= ' <th scope="row"><label for="' . $this->keyword . '">' . $this->name . '</label></th>'; $strHTML .= ' <td>'; $strHTML .= ' <label for="' . $this->keyword. '_alt_desc">Short Description</label><br />'; $strHTML .= ' <input name="' . $this->keyword . '_alt_desc" type="text" id="' . $this->keyword . '_alt_desc" value="' . $this->value->get_alt_desc() . '" size="80" /><br />'; $strHTML .= ' <label for="' . $this->keyword. '_img_url">Image URL</label><br />'; $strHTML .= ' <input name="' . $this->keyword . '_img_url" type="text" id="' . $this->keyword . '_img_url" value="' . $this->value->get_img_url() . '" size="80" /><br />'; $strHTML .= ' <label for="' . $this->keyword. '_web_url">Website</label><br />'; $strHTML .= ' <input name="' . $this->keyword . '_web_url" type="text" id="' . $this->keyword . '_web_url" value="' . $this->value->get_web_url() . '" size="80" />'; $strHTML .= ' <br /><small>' . $this->description . '</small>'; $strHTML .= ' </td>'; $strHTML .= '</tr>'; return $strHTML; } } ?>
At the top of the function __construct value is set, and I confirmed that this is happening.
However, in the bottom function function __toString , $this->value empty.
Any idea what could be causing this?
EDIT
So, to repeat, the value of $ this-> is correctly set in the __construct function, but empty in the __toString function.
EDIT 2
I should also mention that other variables set in the __construct function work in the __toString function, for example the $ this-> keyword. This means that the value of $ this-> is empty.
Edit 3 Class called so
$padd_options['advertisements'] = array( new Padd_Input_Advertisement( PADD_NAME_SPACE . '_ads_125125_1', 'Square Ad 1 (125x125)', 'The advertisement will be posted at the side bar.' ), new Padd_Input_Advertisement( PADD_NAME_SPACE . '_ads_125125_2', 'Square Ad 2 (125x125)', 'The advertisement will be posted at the side bar.' ), new Padd_Input_Advertisement( PADD_NAME_SPACE . '_ads_125125_3', 'Square Ad 3 (125x125)', 'The advertisement will be posted at the side bar.' ), new Padd_Input_Advertisement( PADD_NAME_SPACE . '_ads_125125_4', 'Square Ad 4 (125x125)', 'The advertisement will be posted at the side bar.' ), );