ASPN ActiveState Programmer Network
ActiveState
/ Home / Perl / PHP / Python / Tcl / XSLT /
/ Safari / My ASPN /
Cookbooks | Documentation | Mailing Lists | Modules | News Feeds | Products | User Groups


Recent Messages
List Archives
About the List
List Leaders
Subscription Options

View Subscriptions
Help

View by Topic
ActiveState
.NET Framework
Open Source
Perl
PHP
Python
Tcl
Web Services
XML & XSLT

View by Category
Database
General
SOAP
System Administration
Tools
User Interfaces
Web Programming
XML Programming


MyASPN >> Mail Archive >> php-general
php-general
Re: [PHP] using new AUTOGLOBALS
by Erik Price other posts by this author
Apr 5 2002 3:14PM messages near this date
Re: [PHP] Re: using new AUTOGLOBALS | [PHP] Miguel...
On Friday, April 5, 2002, at 09:55  AM, cyberskydive wrote:

>  So I wanna learn how to code properly with register_globals off, I 
>  reead on

Good idea, it's not really harder than doing it the old way and it helps 
you visualize where your data is coming from.  I actually prefer it this 
way.

>  when I tried to edit an example session script I had from a book to use
>  $_POST, $_REGISTER, or even $_SESSION i got a blank page on the 
>  reload. I
>  think sid is returning empty.

Yes, I have not yet seen a book that uses the register_globals off 
style.  Hopefully that will change as the shift towards register_globals 
off becomes more popular.

>  Can anyone offer me advice on this, proper coding and or proper
>  configuration in PHP.INI

Just turn register_globals off, and make sure you're using PHP 4.1.x or 
greater.  I don't know much about Windows so if there is something wrong 
with your server then somebody else will be a better help.

>  I'm trying to learn all this at once-lol, and learn it properly the 
>  first
>  time around, especially since register globas will be deprecitated-poof.

Yep, that's what I did -- almost from the beginning I've been doing it 
this way.  Just make sure that any time you refer to data that comes 
from one of the superglobals arrays, you use $_*['variablename'] instead 
of just $variablename.  So if you have a cookie with a value of "Fred" 
and a name of "first_name", do $_COOKIE['first_name'] when you want to 
use that variable -- its value is "Fred".

The only one that works a bit different is $_SESSION['variablename'] -- 
it is the easiest way to set session variables.  Just do something like

// user has submitted POST data, and you have
// checked it for errors in your script
$_SESSION['variablename'] = $_POST['variablename'];  // put POST 
variable in a session


How easy is that!
Note that doing this assignment with any other superglobal doesn't work 
and in most cases wouldn't make sense anyway.  For instance, you can't 
set cookies using $_COOKIE['name'] = $name



Erik



----

Erik Price
Web Developer Temp
Media Lab, H.H. Brown
pricee@[...].com


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php
Thread:
cyberskydive
Miguel Cruz
Philip Olson
cyberskydive
Erik Price
Erik Price

Privacy Policy | Email Opt-out | Feedback | Syndication
© ActiveState Software Inc. All rights reserved