News Feed
Sections
News Archive


Community Events
php|tek 2008 PHP Conference



Stoyan Stefanov's Blog:
PHP-style $GLOBALS in Javascript?
1 comment :: posted Wednesday March 12, 2008 @ 07:55:07
voice your opinion now!

In a new post to his blog today, Stoyan Stefanov has a proposal to being something PHP users are very used to - superglobals - over to Javascript.

Javascript has implied globals. When you skip the var in var a = 1; and go a = 1;, then a becomes a global variable. Some consider this an error in the language. [...] In PHP on the other hand, variables are local. [...] So how about this: adopt the $GLOBALS convention in your JavaScripts?

His example proposes the creation of a GLOBALS object you can assign properties to that can be used anywhere. This helps to keep the variables you truely want to be global contained, though it doesn't do much except provide a convention.

tagged with: superglobal global variable javascript




zend cakephp zendframework PEAR developer PHP5 release code application job conference database pecl book security ajax framework releases package mysql

All content copyright, 2008 PHPDeveloper.org :: info@phpdeveloper.org - Powered by the Solar PHP Framework