News Feed
Sections




News Archive
Looking for more information on how to do PHP the right way? Check out PHP: The Right Way

Stoyan Stefanov's Blog:
PHP-style $GLOBALS in Javascript?
March 12, 2008 @ 07:55:07

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.

0 comments voice your opinion now!
superglobal global variable javascript


blog comments powered by Disqus

Similar Posts

DevShed: Cleaning up Array Elements, POST and GET Requests with Filters in PHP 5

Community News: Two Wrappers for Ext JS in PHP - PHP-Ext & ExtPHP

DesignShack.com: How to Build a Dynamic Imgur Upload App Using jQuery & PHP

Ilia Alshanetsky's Blog: httpOnly cookie flag support in PHP 5.2

Paul Jones' Blog: New PDO Behavior In PHP 5.2.1


Community Events





Don't see your event here?
Let us know!


community laravel language interview conference podcast series tool security version release library opinion composer voicesoftheelephpant list framework artisanfiles introduction symfony

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