As miguel suggests, these are just arrays.  Use them like 
any other array:

  print $arr['key'];
  print "string {$arr['key']} string";
  print 'string ' . $arr['key'] . ' string';

Read about arrays and strings:

With the only difference being that they are *super* 
global, so no need for: global $_SERVER;  in your 
functions, etc.

Now if you want to be truly cutting edge :) Then consider 
extract() or import_request_variables() like so:

  import_request_variables('g', 'g_');

Which will allow:
  print $g_foo;  // the GET variable foo

Which is like:
  print $_GET['foo'];
  print $HTTP_GET_VARS['foo'];

See manual entry for more details and features:

The above assumes you want it to be from GET and only GET, 
maybe this is not your desire so modify accordingly.

Or let's say you want to use server predefined variables such 
as $PHP_SELF, $DOCUMENT_ROOT, etc. yet have register_globals 
remain off.  Since register_globals = on creates these, 

  a) Using $_SERVER or $HTTP_SERVER_VARS in your code i.e.
       print $_SERVER['HTTP_USER_AGENT'];
  b) Or use extract()

For example:

  // If register_globals are off (0) then extract
  if (!ini_get('register_globals')) {

  // We just created these!
  print $PHP_SELF;
  print $REQUEST_URI;

Going through $_SERVER is good in that you're not wasting 
energy creating variables you'll never use, so do as 
you will.

extract() has many many options, read about them:

All of the above should give ideas, have fun!

Philip Olson

p.s. Use a mirror

On Fri, 5 Apr 2002, Miguel Cruz wrote:

> On Fri, 5 Apr 2002, cyberskydive wrote:
> > So I wanna learn how to code properly with register_globals off, I reead on
> > about the new auto globals and inmy new php4.1.2 windows
> > installation using php.ini-rec edited according to the intall.txt file, and
> > a few changes from books I have (upload tmp dir etc) I'm off to learn how to
> > use the new auto globals. I've tried $_REGISTER and $_POST .  Here is what I
> > tried as a simple test.
> > 
> > <form method="post" action="somefile.php">
> > <input type="text" name="is_name">
> > <input type="submit">
> > </form>
> > 
> > --somefile.php--
> > 
> > <?
> > 
> > print("$_REGISTER["is_name"]");
> > or
> > print("$_POST["is_name"]");
> > 
> > ?>
> Two problems.
> 1) It's $_REQUEST, not $_REGISTER
> 2) Take the outermost quotes off the argument to your print, like so:
>    print $_REQUEST["is_name"];
> miguel
> -- 
> PHP General Mailing List (
> To unsubscribe, visit:

PHP General Mailing List (
To unsubscribe, visit:

Reply via email to