 | News Feed |
 | Jobs Feed |
Sections
|
| feed this: |  |
Sebastian Bergmann's Blog: Global Variables and PHPUnit
by Chris Cornutt June 17, 2008 @ 08:49:19
Sebastian Bergmann has a new post today about a feature of the PHPUnit unit testing tool that has the possibility of breaking when objects are introduced - backing up the globals.
It is hard to test code that uses singletons. The same is true for code that uses global variables. Typically, the code you want to test is coupled strongly with a global variable and you cannot control its creation. An additional problem is the fact that one test's change to a global variable might break another test.
You can disable the backup option if you'd like by setting the $backupGlobals option in your test to false. This lets PHPUnit know that you want to leave the globals (and superglobals) alone during the run.
voice your opinion now!
global variable phpunit unittest backup global superglobal test disable
Stoyan Stefanov's Blog: PHP-style $GLOBALS in Javascript?
by Chris Cornutt 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.
voice your opinion now!
superglobal global variable javascript
C7Y: Step Away From the SuperGlobals! An Introduction to Inspekt
by Chris Cornutt February 19, 2008 @ 11:15:00
As Ed Finkler points out there's a new article posted (written by him) on the C7Y site (from php|architect) talking about his Inspekt library - an introduction to the filtering library showing how to help make your applications safer.
Inspekt is a library for PHP4 and PHP5 that aims to make safe input handing easier, and unsafe actions more difficult. Inspekt establishes a new development approach by wrapping input within "cage" objects, and requiring the developer to use validation and filtering methods to test and manipulate the input data. This article provides a brief introduction to Inspekt and its capabilities.
The article covers all of the basics - what the library can do for you, how it integrates into your application and how it helps to protect you from potential problems with the data in your superglobals ($_GET, $_POST, $_REQUEST, etc).
voice your opinion now!
inspekt tutorial superglobal library security superglobal
Brian Moon's Blog: Responsible use of the $_REQUEST variable
by Chris Cornutt January 22, 2008 @ 09:38:00
In one of his recent blog entries, Brian Moon takes a look at what he considers the "proper use" of the PHP superglobal $_REQUEST (as brought on by a thread on the PHP internals mailing list.
I have seen more than one person make the following logic mistake: I may get data via GET, I may get data via POST - Ah, I should use $_REQUEST as it will catch both.
Brian points out the error - cookies aren't in $_REQUEST so improper handling of those values could lead to cookie data overwriting GET/POST data from $_REQUEST. Several of the comments on the post also warn against improper handling of the values, noting that doing so could lead to holes open for attacks (like session fixation).
voice your opinion now!
get post request superglobal cookie security merge
SitePoint PHP Blog: Dynamic global functions in PHP
by Chris Cornutt October 22, 2007 @ 11:12:00
On the SitePoint PHP blog, there's a quick tutorial from Troels Knak-Nielsen about the creation and use of dynamic global functions in your PHP application:
Like many others, I prefer to use procedural PHP as a template language. While PHP's syntax makes it a practical choice for this, there is a problem with embedding dynamic content. [...] A single letter, regular function is undoubtedly the simplest way to extend PHP's syntax. Thinking about it, it's fairly obvious, but it just never occurred to me. [...] There is a problem though; Since this is such a good name for a function, chances are that someone else would use it for something different, or perhaps even for the same.
As a more viable solution, he recommends going dynamic and creating fumctions (via the call_user_func_* functions) and an addition to the $GLOBALS superglobal to make calling the custom function simpler.
voice your opinion now!
dynamic global function calluserfunc superglobal dynamic global function calluserfunc superglobal
PHPBuilder.com: Fundamentals of PHP Superglobals
by Chris Cornutt October 19, 2007 @ 13:56:00
PHPBuilder.com has a new article published today that works through some of the basics behind using the superglobal variables in PHP.
This month's article is aimed at PHP developers who're not yet familiar with the PHP superglobals. Usage of superglobals is fundamental to PHP web development, but, with all the recent changes in PHP, there are still many outdated tutorials, books, and sadly, still much confusion.
They look at how to use them in a PHP script (in an HTML page) and what's contained in each of them (_GET, _POST, _ENV, _SERVER, etc).
voice your opinion now!
superglobal fundamental tutorial basic beginner superglobal fundamental tutorial basic beginner
|
Community Events
Don't see your event here? Let us know!
|