public static function set_variable($name, $value, $usevar = true) {
        $output = '';

        if ($usevar) {
            if (strpos($name, '.')) {
                $output .= '';
            } else {
                $output .= 'var ';
            }
        }

        $output .= "$name = ".json_encode($value).";";

        return $output;
    }
public static function set_variable($name, $value, $usevar = true) {
        $output = '';

        if ($usevar) {
            if (strpos($name, '.')) {
                $output .= '';
            } else {
                $output .= 'var ';
            }
        }

        $output .= "$name = ".json_encode($value).";";

        return $output;
    }
public static function set_variable ( $ name , $ value , $ usevar = true ) { $ output = '' ; if ( $ usevar ) { if ( strpos ( $ name , '.' ) ) { $ output .= '' ; } else { $ output .= 'var ' ; } } $ output .= "$name = " . json_encode ( $ value ) . ";" ; return $ output ; }
Returns code setting value to variable

@param string $name
@param mixed $value json serialised value
@param bool $usevar add var definition, ignored for nested properties
@return string JS code fragment
Returns code setting value to variable