Banner

Sponsor

Login


Welcome Back!
Guest
Guest

Register

Lost your password?

193 users online



Tutorial: GPC variables the good way!

Tutorial: GPC variables the good way!

Currently viewing this thread: 1 (0 members and 1 guests)


Page 2 out of 3
Phil

Phil

with Mr. Jones
Status: Offline!
Quote:

Originally posted by EvilGenius
yeah i saw the function, but mine automatically remove slashes to all GPC vars, i dont need to call it when i need the variable Shocked

Yeah, I noticed that - I don't do it that way because i dont need it to do it to all vars.

___________________

http://www.philbrodeur.com - Expert PHP Development and Tutorials

Jeremie

Jeremie

Neversidian
Status: Offline!

Jeb: Thanks! Smile

Ares: I think you have a point here, but since I use almost every GPC vars that i set, i do it that way

___________________

Jeremie - Used to be the Director of Community Development

amplify

amplify

I'm a Neverside Newbie?
Status: Offline!

foreach($_POST as $name=>$value) {
eval("\$POST_{$name}&=$value;");
}
foreach($_GET as $name=>$value) {
eval("\$GET_{$name}&=$value;");
}
and so on.

Last edited by CDude, July 5th, 2003 07:09 AM (Edited 1 times)

CDude

CDude

nothing
Status: Offline!
Quote:

Originally posted by aMpLiFy
foreach($_POST as $name=>$value) {
eval("\$POST_{$name}&=$value;");
}
foreach($_GET as $name=>$value) {
eval("\$GET_{$name}&=$value;");
}
and so on.

or extract($_GET, EXTR_OVERWRITE, 'GET_');

___________________

http://celerondude.com

Jeremie

Jeremie

Neversidian
Status: Offline!

You can use
${'POST_' . $name}
instead of
eval("$POST_{$name}")

___________________

Jeremie - Used to be the Director of Community Development

amplify

amplify

I'm a Neverside Newbie?
Status: Offline!
Quote:

Originally posted by CDude
or extract($_GET, EXTR_OVERWRITE, 'GET_');

yes, but the advantage of doing it my way is: &=

extract() will just make them normal variables.

CDude

CDude

nothing
Status: Offline!

have you looked at your code?

let's take the GET array for example.

index.php?name=James

the eval would be

$GET_name =& $James;

There is no variable $James;

You'd need quotes around $name and can't use reference.

___________________

http://celerondude.com

Jeb

Jeb

Status: Offline!
PHP:

<?php

foreach($_SERVER as $key=>$val)
{
    ${
$key} =& $_SERVER[$key];
}
?>

I believe that's what you're thinking of, amp. You want to make a reference to the superglobal array index. Since you can't make a reference to a string, I assumed this is where you were heading.

___________________

Adam Goossens -- PHP is my mother tounge.

Linux: ( kernel.org | winehq ) -- f33l the p0w3r.

Nobody replying to your questions? Getting flamed? Getting told to RTFM? Ask your questions the right way.

Jeremie

Jeremie

Neversidian
Status: Offline!

what's the point of this? I mean referencing every GPC vars..

Maybe adding quick compatibility for older scripts that didnt used the superglobals. But not for newer scripts

___________________

Jeremie - Used to be the Director of Community Development

amplify

amplify

I'm a Neverside Newbie?
Status: Offline!

It's been months since I've touched PHP... didn't even realize I had the =& backwards and that references aren't for strings. Sad

Last edited by amplify, July 7th, 2003 06:43 PM (Edited 1 times)

Page 2 out of 3
Quick Jump:

Main Navigation


Site & Graphic Design by Aeon Tan
Developed by Jeremie Pelletier & Scott Roach


NeverAPI generated this page in 0.0083 seconds.