public function set_var($variable, $data)
    {
        $this->last_selector = null;

        if (!empty($data) && is_array($data)) {
            foreach ($data as $name => $d) {
                $data[$name] = $this->typecast($d, true, true);
            }
        } else {
            $data = $this->typecast($data, true, true);
        }

        return $this->cmd(9, array(
            !is_array($variable) ? array($variable) : $variable,
            array($data)
        ));
    }
public function set_var($variable, $data)
    {
        $this->last_selector = null;

        if (!empty($data) && is_array($data)) {
            foreach ($data as $name => $d) {
                $data[$name] = $this->typecast($d, true, true);
            }
        } else {
            $data = $this->typecast($data, true, true);
        }

        return $this->cmd(9, array(
            !is_array($variable) ? array($variable) : $variable,
            array($data)
        ));
    }
public function set_var ( $ variable , $ data ) { $ this -> last_selector = null ; if ( ! empty ( $ data ) && is_array ( $ data ) ) { foreach ( $ data as $ name => $ d ) { $ data [ $ name ] = $ this -> typecast ( $ d , true , true ) ; } } else { $ data = $ this -> typecast ( $ data , true , true ) ; } return $ this -> cmd ( 9 , array ( ! is_array ( $ variable ) ? array ( $ variable ) : $ variable , array ( $ data ) ) ) ; }
Set a global variable, that can be accessed directly through window object,
can set properties inside objects if you pass an array as the variable.
If it doesn't exist it will be created

<code>
// window.customer_info = {'name': 'John','surname': 'Doe', 'age': 39}
PheryResponse::factory()->set_var('customer_info', array('name' => 'John', 'surname' => 'Doe', 'age' => 39));
</code>

<code>
// window.customer_info.name = 'John'
PheryResponse::factory()->set_var(array('customer_info','name'), 'John');
</code>

@param string|array $variable Global variable name
@param mixed $data Any data
@return PheryResponse
Set a global variable that can be accessed directly through window object can set properties inside objects if you pass an array as the variable . If it doesn t exist it will be created