---
layout: page
title: "JavaScript get_cfg_var function"
comments: true
sharing: true
footer: true
alias:
- /functions/view/get_cfg_var:776
- /functions/view/get_cfg_var
- /functions/view/776
- /functions/get_cfg_var:776
- /functions/776
---
<!-- Generated by Rakefile:build -->
A JavaScript equivalent of PHP's get_cfg_var

{% codeblock info/get_cfg_var.js lang:js https://raw.github.com/kvz/phpjs/master/functions/info/get_cfg_var.js raw on github %}
function get_cfg_var (varname) {
  // http://kevin.vanzonneveld.net
  // +   original by: Brett Zamir (http://brett-zamir.me)
  // %        note 1: The ini values must be set within an ini file
  // *     example 1: get_cfg_var('date.timezone');
  // *     returns 1: 'Asia/Hong_Kong'
  if (this.php_js && this.php_js.ini && this.php_js.ini[varname].global_value !== undefined) {
    if (this.php_js.ini[varname].global_value === null) {
      return '';
    }
    return this.php_js.ini[varname].global_value;
  }
  return '';
}
{% endcodeblock %}

 - [view on github](https://github.com/kvz/phpjs/blob/master/functions/info/get_cfg_var.js)
 - [edit on github](https://github.com/kvz/phpjs/edit/master/functions/info/get_cfg_var.js)

### Example 1
This code
{% codeblock lang:js example %}
get_cfg_var('date.timezone');
{% endcodeblock %}

Should return
{% codeblock lang:js returns %}
'Asia/Hong_Kong'
{% endcodeblock %}


### Other PHP functions in the info extension
{% render_partial _includes/custom/info.html %}
