Implicit Evaluation with PHP

Implicit Evaluation with PHP Archives: PHP

next page · previous page

23 January 2007

What is $_REQUEST, or the difference between $_REQUEST, $_GET and $_POST

PHP provides you a number of “super-global” variables. These include $_GET, $_POST, $_COOKIE, $_SESSION, $_SERVER, $_ENV, $_FILES and $_REQUEST. Most of these are fairly self-explainatory. $_GET are the variables passed by forms with a GET method or after the end of the path such as example.com/search.php?GETARG1=GETVAL1&foo=bar. $_POST is any variable submitted by a form with […]

continue reading... » One Comment

18 January 2007

Loops in PHP

PHP gives programmers many varieties of loops to work with. Despite an overwhelming selection, each is tailored, really, to just one scenario.

continue reading... » One Comment

1 January 2007

Recursive Data Structures in PHP

Welcome to the Jungle
Today, I was helping a friend implement a recursive category model. There is a top level category and each category contains items and sub-categories.
It’s easy to illustrate on the web:

Top Level Category

Item 1.1
Item 1.2
Subcategory 1.3

Item 3.1
Item 3.2

Subcategory 1.4

Subcategory 4.1

Subcategory 4.1.1

Item 4.1.1.1
Item 4.1.1.2

Item 4.1.2

Somehow, your web browser can take a piece of text […]

continue reading... » 0 Comments

22 December 2006

Determining if method is a static class method or dynamic object method

Up until PHP5, there was no way to designate a function as static or instantiated. The difference is small, but important. Object methods can only be called through an instantiated object and have access to a class’s member variables. A static class method does not have access to object data but also needs not be […]

continue reading... » 0 Comments

7 December 2006

The Difference Between PHP’s Globals and Superglobals

PHP only has two variable scopes: local and global. But it has three considerations for scoping variables: local, global and superglobal. What exactly is a superglobal?
The only superglobal variables in PHP are

$_POST
$_GET
$_REQUEST
$_COOKIE
$_SERVER
$_SESSION
$_ENV
$_FILES

These are the variables that PHP just gives you which few other languages offer. There is no way to create your own superglobal but […]

continue reading... » 0 Comments

20 November 2006

Comparing array_key_exists With isset

There are two functions for determining the existence of elements in an array: isset and array_key_exists. They are very similar in use, but there are subtle differences.
The biggest difference is speed. array_key_exists takes about 33% longer to execute than isset. For just a few checks, it’s a negligible difference. But in a loop, it will […]

continue reading... » 0 Comments

20 November 2006

Dynamic Image Generation in PHP

Through use of the GD libraries, it’s long been possible to write images in code with PHP. They’re unlikely to be photographic quality, but for captcha’s, counters, charts, etc, it’s unlikely that it needs to be. But this particular feature seems to be generally overlooked. PHP: Dynamic Image Generation is a nice tutorial for using […]

continue reading... » 2 Comments

14 November 2006

History of the World Part XIV: Wherein PHP Assumes Babysitting Responsibilities

I’m a responsible programmer. Really, I am. I ask for advice from my peers whenever the path points to something I feel unsure about. I use (perhaps overuse, but thats another column) functions responsibility. Regardless of what the user is told, I protect against user input internally. And so when I want to write a […]

continue reading... » 0 Comments

31 October 2006

Modifying Recursive Data Structures in PHP

I’ve been working on code to allow pure HTML pages to be used as the source code of templates. Compiling this HTML mandates the use of a recursive data structure to form a tree of HTML tags and to preserve the textual content of the page. It’s reasonably easy to do in PHP5 because of […]

continue reading... » 2 Comments

28 October 2006

Eval in a Sandbox

You might call me an outspoken critic of eval.
However, it can sometimes be a necessary evil. Even when eval is the only way to solve a problem, it’s still a security concern. Therefore, I’d like to present a well-to-do way to call eval. It can still let perpetrators call system(”rm -rf /”) but at does […]

continue reading... » 0 Comments

next page · previous page