PHP Development
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me

The Shed is going Social! Join us on FaceBook and Twitter and chime in on the conversation.

Go Back   Dev Shed ForumsProgramming LanguagesPHP Development

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Dev Shed Forums Sponsor:
  #1  
Old January 18th, 2013, 11:28 AM
WrinkledCheese's Avatar
WrinkledCheese WrinkledCheese is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Jun 2011
Posts: 138 WrinkledCheese User rank is Second Lieutenant (5000 - 10000 Reputation Level)WrinkledCheese User rank is Second Lieutenant (5000 - 10000 Reputation Level)WrinkledCheese User rank is Second Lieutenant (5000 - 10000 Reputation Level)WrinkledCheese User rank is Second Lieutenant (5000 - 10000 Reputation Level)WrinkledCheese User rank is Second Lieutenant (5000 - 10000 Reputation Level)WrinkledCheese User rank is Second Lieutenant (5000 - 10000 Reputation Level)WrinkledCheese User rank is Second Lieutenant (5000 - 10000 Reputation Level) 
Time spent in forums: 1 Day 16 h 13 m 36 sec
Reputation Power: 96
Variable _POST or _GET

Hello everyone,

I'm mostly curious why this code doesn't work 100%.

http://192.168.1.100/test.php?variable=value
PHP Code:
Original - PHP Code
  1. $test = "some text to test with";
  2. $print = "test";
  3. echo $$print;
  4. $dataLocation = "_GET";
  5. $keys = array_keys($$dataLocation);
  6. foreach($_GET as $k => $v){
  7.   echo $k . " => " . $v . "<br>";
  8. }


Code:
Results
some text to test with
Notice: Undefined variable: _GET in test.php on line 5
variable => value

Reply With Quote
  #2  
Old January 18th, 2013, 11:56 AM
requinix's Avatar
requinix requinix is offline
Still alive
Click here for more information.
 
Join Date: Mar 2007
Location: Washington, USA
Posts: 12,679 requinix User rank is General 120th Grade (Above 100000 Reputation Level)requinix User rank is General 120th Grade (Above 100000 Reputation Level)requinix User rank is General 120th Grade (Above 100000 Reputation Level)requinix User rank is General 120th Grade (Above 100000 Reputation Level)requinix User rank is General 120th Grade (Above 100000 Reputation Level)requinix User rank is General 120th Grade (Above 100000 Reputation Level)requinix User rank is General 120th Grade (Above 100000 Reputation Level)requinix User rank is General 120th Grade (Above 100000 Reputation Level)requinix User rank is General 120th Grade (Above 100000 Reputation Level)requinix User rank is General 120th Grade (Above 100000 Reputation Level)requinix User rank is General 120th Grade (Above 100000 Reputation Level)requinix User rank is General 120th Grade (Above 100000 Reputation Level)requinix User rank is General 120th Grade (Above 100000 Reputation Level)requinix User rank is General 120th Grade (Above 100000 Reputation Level)requinix User rank is General 120th Grade (Above 100000 Reputation Level)requinix User rank is General 120th Grade (Above 100000 Reputation Level)  Folding Points: 417516 Folding Title: Super Ultimate Folder - Level 1Folding Points: 417516 Folding Title: Super Ultimate Folder - Level 1Folding Points: 417516 Folding Title: Super Ultimate Folder - Level 1Folding Points: 417516 Folding Title: Super Ultimate Folder - Level 1Folding Points: 417516 Folding Title: Super Ultimate Folder - Level 1Folding Points: 417516 Folding Title: Super Ultimate Folder - Level 1
Time spent in forums: 5 Months 1 Week 4 Days 1 h 46 m 33 sec
Reputation Power: 8969
Send a message via AIM to requinix Send a message via MSN to requinix Send a message via Yahoo to requinix Send a message via Google Talk to requinix
auto_globals_jit. When PHP reads your code it sees references to $_GET and $_SESSION and such and makes sure they're available. Since you try to use one before you explicitly mention it there's no guarantee it will actually exist.

Try this.
PHP Code:
// you don't even have to use it
$_GET;

$test "some text to test with";
$print "test";
echo $
$print;
$dataLocation "_GET";
$keys array_keys($$dataLocation);
foreach(
$_GET as $k => $v){
  echo 
$k " => " $v "<br>";

Comments on this post
ManiacDan agrees!

Reply With Quote
  #3  
Old January 18th, 2013, 12:28 PM
WrinkledCheese's Avatar
WrinkledCheese WrinkledCheese is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Jun 2011
Posts: 138 WrinkledCheese User rank is Second Lieutenant (5000 - 10000 Reputation Level)WrinkledCheese User rank is Second Lieutenant (5000 - 10000 Reputation Level)WrinkledCheese User rank is Second Lieutenant (5000 - 10000 Reputation Level)WrinkledCheese User rank is Second Lieutenant (5000 - 10000 Reputation Level)WrinkledCheese User rank is Second Lieutenant (5000 - 10000 Reputation Level)WrinkledCheese User rank is Second Lieutenant (5000 - 10000 Reputation Level)WrinkledCheese User rank is Second Lieutenant (5000 - 10000 Reputation Level) 
Time spent in forums: 1 Day 16 h 13 m 36 sec
Reputation Power: 96
Unfortunately this quick fix didn't work, but at least I know why it's happening, I think.

I went so far as to do this at the top of my script:

PHP Code:
Original - PHP Code
  1. $_GET['init'] = 'JIT INIT';


I've also tried:
PHP Code:
Original - PHP Code
  1. ini_set('auto_globals_jit', 'Off');


As well as going into the php.ini file turning it off there and restarting the server. No difference. I also have a var_dump($_GET); and that shows that there is stuff in the $_GET array.

Last edited by WrinkledCheese : January 18th, 2013 at 12:39 PM.

Reply With Quote
  #4  
Old January 18th, 2013, 12:45 PM
ManiacDan's Avatar
ManiacDan ManiacDan is offline
Likely to be eaten by a grue.
Dev Shed God 10th Plane (9500 - 9999 posts)
 
Join Date: Oct 2006
Location: Pennsylvania, USA
Posts: 9,791 ManiacDan User rank is General 77th Grade (Above 100000 Reputation Level)ManiacDan User rank is General 77th Grade (Above 100000 Reputation Level)ManiacDan User rank is General 77th Grade (Above 100000 Reputation Level)ManiacDan User rank is General 77th Grade (Above 100000 Reputation Level)ManiacDan User rank is General 77th Grade (Above 100000 Reputation Level)ManiacDan User rank is General 77th Grade (Above 100000 Reputation Level)ManiacDan User rank is General 77th Grade (Above 100000 Reputation Level)ManiacDan User rank is General 77th Grade (Above 100000 Reputation Level)ManiacDan User rank is General 77th Grade (Above 100000 Reputation Level)ManiacDan User rank is General 77th Grade (Above 100000 Reputation Level)ManiacDan User rank is General 77th Grade (Above 100000 Reputation Level)ManiacDan User rank is General 77th Grade (Above 100000 Reputation Level)ManiacDan User rank is General 77th Grade (Above 100000 Reputation Level)ManiacDan User rank is General 77th Grade (Above 100000 Reputation Level)ManiacDan User rank is General 77th Grade (Above 100000 Reputation Level)ManiacDan User rank is General 77th Grade (Above 100000 Reputation Level)  Folding Points: 127430 Folding Title: Super Ultimate Folder - Level 1Folding Points: 127430 Folding Title: Super Ultimate Folder - Level 1Folding Points: 127430 Folding Title: Super Ultimate Folder - Level 1Folding Points: 127430 Folding Title: Super Ultimate Folder - Level 1Folding Points: 127430 Folding Title: Super Ultimate Folder - Level 1Folding Points: 127430 Folding Title: Super Ultimate Folder - Level 1
Time spent in forums: 2 Months 3 Weeks 14 h 53 m 20 sec
Reputation Power: 6112
From the manual

Quote:
Originally Posted by RTFM Requinix
Please note that variable variables cannot be used with PHP's Superglobal arrays within functions or class methods. The variable $this is also a special variable that cannot be referenced dynamically.
Comments on this post
WrinkledCheese agrees: This is my issue. Thanks! 96 points for your....collection
__________________
HEY! YOU! Read the New User Guide and Forum Rules

"They that can give up essential liberty to obtain a little temporary safety deserve neither liberty nor safety." -Benjamin Franklin

"The greatest tragedy of this changing society is that people who never knew what it was like before will simply assume that this is the way things are supposed to be." -2600 Magazine, Fall 2002

Think we're being rude? Maybe you asked a bad question or you're a Help Vampire. Trying to argue intelligently? Please read this.

Reply With Quote
  #5  
Old January 18th, 2013, 12:47 PM
requinix's Avatar
requinix requinix is offline
Still alive
Click here for more information.
 
Join Date: Mar 2007
Location: Washington, USA
Posts: 12,679 requinix User rank is General 120th Grade (Above 100000 Reputation Level)requinix User rank is General 120th Grade (Above 100000 Reputation Level)requinix User rank is General 120th Grade (Above 100000 Reputation Level)requinix User rank is General 120th Grade (Above 100000 Reputation Level)requinix User rank is General 120th Grade (Above 100000 Reputation Level)requinix User rank is General 120th Grade (Above 100000 Reputation Level)requinix User rank is General 120th Grade (Above 100000 Reputation Level)requinix User rank is General 120th Grade (Above 100000 Reputation Level)requinix User rank is General 120th Grade (Above 100000 Reputation Level)requinix User rank is General 120th Grade (Above 100000 Reputation Level)requinix User rank is General 120th Grade (Above 100000 Reputation Level)requinix User rank is General 120th Grade (Above 100000 Reputation Level)requinix User rank is General 120th Grade (Above 100000 Reputation Level)requinix User rank is General 120th Grade (Above 100000 Reputation Level)requinix User rank is General 120th Grade (Above 100000 Reputation Level)requinix User rank is General 120th Grade (Above 100000 Reputation Level)  Folding Points: 417516 Folding Title: Super Ultimate Folder - Level 1Folding Points: 417516 Folding Title: Super Ultimate Folder - Level 1Folding Points: 417516 Folding Title: Super Ultimate Folder - Level 1Folding Points: 417516 Folding Title: Super Ultimate Folder - Level 1Folding Points: 417516 Folding Title: Super Ultimate Folder - Level 1Folding Points: 417516 Folding Title: Super Ultimate Folder - Level 1
Time spent in forums: 5 Months 1 Week 4 Days 1 h 46 m 33 sec
Reputation Power: 8969
Send a message via AIM to requinix Send a message via MSN to requinix Send a message via Yahoo to requinix Send a message via Google Talk to requinix
You can't ini_set() it on - it's too late in the process.

What's the exact script you're using to reproduce this problem? Does it involve classes or functions like Dan pointed out?

Reply With Quote
  #6  
Old January 21st, 2013, 07:41 AM
WrinkledCheese's Avatar
WrinkledCheese WrinkledCheese is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Jun 2011
Posts: 138 WrinkledCheese User rank is Second Lieutenant (5000 - 10000 Reputation Level)WrinkledCheese User rank is Second Lieutenant (5000 - 10000 Reputation Level)WrinkledCheese User rank is Second Lieutenant (5000 - 10000 Reputation Level)WrinkledCheese User rank is Second Lieutenant (5000 - 10000 Reputation Level)WrinkledCheese User rank is Second Lieutenant (5000 - 10000 Reputation Level)WrinkledCheese User rank is Second Lieutenant (5000 - 10000 Reputation Level)WrinkledCheese User rank is Second Lieutenant (5000 - 10000 Reputation Level) 
Time spent in forums: 1 Day 16 h 13 m 36 sec
Reputation Power: 96
Quote:
Originally Posted by requinix
You can't ini_set() it on - it's too late in the process.

What's the exact script you're using to reproduce this problem? Does it involve classes or functions like Dan pointed out?


It is in a function.

Reply With Quote
Reply

Viewing: Dev Shed ForumsProgramming LanguagesPHP Development > Variable _POST or _GET

Developer Shed Advertisers and Affiliates



Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump

Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 


Powered by: vBulletin Version 3.0.5
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.

© 2003-2013 by Developer Shed. All rights reserved. DS Cluster - Follow our Sitemap