19, March 2010

register_globals - webmaster forum

 
Webdigity webmaster forums
[ Home | Help | Search | Forum's Shop | Archive | Login | Register | Webmaster Directory ]
Webdigity Webmaster Forums  >  Web Development  >  PhP
Topic: register_globals
« previous next »
Pages: [1] Print

Author Topic: register_globals  (Read 1072 times)
Where are my glasses?
*
Posts: 21
138 credits
Members referred : 0


« on: Jul 19, 2007, 03:04:11 pm »

Hello,

regarding to http://www.webdigity.com/index.php?action=tutorial;code=39 I wanted to mention that there are some other possibilities to "emulate" an enabled register_globals.

Code:
<?php
 
foreach ( $_REQUEST as $k => $v )
 {
   eval ( 
"\$$k = '$v';" );
 }
?>


<?php
  
foreach ($_REQUEST as $key => $value)
  {
     $
$key $value;
  }
?>


<?php
  extract
($_REQUEST);
?>

register_globals stores $_REQUEST (not just $_GET) in variables.

Best regards,
Tim
« Last Edit: Jul 19, 2007, 03:34:21 pm by Nikolas »
I am a metal monkey!
Administrator
Community Supporter ?
Jedai Sword Master
*****
Gender: Male
Posts: 5659
45587 credits
Members referred : 3



« Reply #1 on: Jul 19, 2007, 03:35:31 pm »

Interesting, I didn't know the extract() function. Thanks for the heads up Smiley

And welcome to webdigity Smiley

Trial and Error my two best teachers Cool
Join us @ facebook or twitter

Last blog : Butterfly Marketing 2.0
Global Moderator
Community Supporter ?
Jedai Sword Master
*****
Gender: Male
Posts: 6690
34708 credits
Members referred : 374


It's time to use PHP5!


« Reply #2 on: Jul 19, 2007, 04:14:02 pm »

and how about this duplication thing you have to fight with register_globals = on?

$var
$_GET['var']
$_POST['var']
$_COOKIE['var']

or just $_REQUEST['var']

and there is still
session_register('var')

Cheesy

I think its easier to work with register_globals = off

(I hate every moment I used to create scripts working with register_globals = on)

...and welcome to webdigity redredred Wink


Last blog : A new Wordpress theme for our blog
I am a metal monkey!
Administrator
Community Supporter ?
Jedai Sword Master
*****
Gender: Male
Posts: 5659
45587 credits
Members referred : 3



« Reply #3 on: Jul 19, 2007, 06:23:47 pm »

Yeah right, with no registered globals is much better. I had posted this tutorial just for Meth0d who wanted registered globals and his host didn't had this directive on.

Trial and Error my two best teachers Cool
Join us @ facebook or twitter

Last blog : Butterfly Marketing 2.0
Global Moderator
Community Supporter ?
Jedai Sword Master
*****
Gender: Male
Posts: 6690
34708 credits
Members referred : 374


It's time to use PHP5!


« Reply #4 on: Jul 19, 2007, 06:29:48 pm »

Yeah right, with no registered globals is much better. I had posted this tutorial just for Meth0d who wanted registered globals and his host didn't had this directive on.

I know Wink


Last blog : A new Wordpress theme for our blog
Where are my glasses?
*
Posts: 21
138 credits
Members referred : 0


« Reply #5 on: Jul 20, 2007, 02:02:12 am »

Thank you! I think the best way is to have register_globals deactivated. extract() can make sense if you need a template engine which can interpret PHP code.
I am a metal monkey!
Administrator
Community Supporter ?
Jedai Sword Master
*****
Gender: Male
Posts: 5659
45587 credits
Members referred : 3



« Reply #6 on: Jul 20, 2007, 11:24:54 am »

In most cases you need to validate data for mysql queries. So I guess you will need to do something like :

$id = (int) $_GET['id'];?>

On the other hand if you are using registered globals, the order that the variables are registered (get, post, etc.) can be different in different hosts and that can be a huge headeache Smiley

Trial and Error my two best teachers Cool
Join us @ facebook or twitter

Last blog : Butterfly Marketing 2.0
Trackback URI for this entry : http://www.webdigity.com/trackback.php?topic=6930
Tags : register_globals php $_REQUEST $_GET Bookmark this thread : Digg Del.icio.us Dzone more....

Pages: [1] Print 
Webdigity Webmaster Forums  >  Web Development  >  PhP
Topic: register_globals
« previous next »
Jump to:
User Area
Welcome, Guest. Please login or register.
Did you miss your activation email?
Mar 19, 2010, 01:54:15 pm





Login with username, password and session length

Donate to our community, and get a permanent link back to your site!

Donate to our community, and get a permanent link back to your site!


Forum Statistics
Total Posts: 44.201
Total Topics: 8.622
Total Members: 8.232
Tutorials : 58
Resources : 929
Designs : 360
Latest Member: maritimepart

37 Guests, 5 Users online :

14 users online today:



Readers

Web Design Gallery · Whois Lookup · Pagerank · Tag Browsing · Lo-fi version · Syndication · Webmaster forum history · Advertise
Developed by HumanWorks © 2005 - 2010 Webdigity webmaster community · sublime directory
Webdigity Webmaster Forums | Powered by SMF 1.0.12. © 2001-2005, Lewis Media. All Rights Reserved.