NandoBas
NandoBas

Reputation: 21

Creating default object from empty value

I need to set the object variable at run time, it is working, but PHP returns me:

Creating default object from empty value (/sct/fw FW_List.class.php:1142)

function initTemplates(&$object, $tpl_names)
{

 global $FW_LIST_CONFIGURATION;
     $is_custom = array();

     foreach($tpl_names as $tpl_type) {
        $object->$tpl_type =  new template();
        $object->$tpl_type->setTemplateText($FW_LIST_CONFIGURATION["templates"][$tpl_type]);
            // place the defauts template values
        $object->$tpl_type->setPlace( $FW_LIST_CONFIGURATION["css"][$tpl_type]);
  }
  return $is_custom;
}

ps. i can't use $object = new stdClass, because $object is a pointer.

Upvotes: 1

Views: 1823

Answers (1)

NandoBas
NandoBas

Reputation: 21

resolved, the secret was to use Array;

$object->test[$tpl_type] =  new template();
$object->$tpl_type = $object->test[$tpl_type];
$object->$tpl_type->setTemplateText($FW_LIST_CONFIGURATION["templates"][$tpl_type]);

Upvotes: 1

Related Questions