Description |
Category: Bug |
| Wrong |
function hello_world()
{ if (empty($HTTP_GET_VARS['name'])) { // $HTTP_GET_VARS is always undefined in this context print "Hello, stranger!"; } else { print "Hello, $HTTP_GET_VARS[name]"; } } |
|
Correct alternative #1 |
function hello_world()
{ global $HTTP_GET_VARS; if (empty($HTTP_GET_VARS['name'])) { print "Hello, stranger!"; } else { print "Hello, $HTTP_GET_VARS[name]"; } } |
|
Correct alternative #2 (recommended) |
function hello_world()
{ if (empty($_GET['name'])) { print "Hello, stranger!"; } else { print "Hello, $_GET[name]"; } } |