NuSphere Forums Forum Index
NuSphere Forums
Reply to topic
How do I debug a php file with "fake" server vars?


Joined: 15 Apr 2008
Posts: 3
Reply with quote
simulating GET/POST, etc variables specifically entered by the user.
View user's profileFind all posts by Darko74Send private message
Guru master

Joined: 05 Jul 2004
Posts: 659
Location: Belgium
Reply with quote
Since $_GET and $_POST are writable, you can just fill them in yourself. Just add things like $_GET [ 'variable' ] = 'value'; before your actual code starts.
If you don't want do modify your actual code, you can do this in a separate php file and define it as the auto_prepend_file in php.ini (make sure to remove this again after testing)
View user's profileFind all posts by BlizzSend private messageVisit poster's website


Joined: 15 Apr 2008
Posts: 3
Reply with quote
Thanks for your reply blizz!

I'll do it that way for the moment, but it would be great if there was some feature that allowed you to specify server vars by yourself just before debugging, without the need to edit the code (people absent-minded like me might forget the patched code when uploading it to the server). Wink
View user's profileFind all posts by Darko74Send private message
Guru master

Joined: 05 Jul 2004
Posts: 659
Location: Belgium
Reply with quote
If you work with the "auto_prepend_file""-php directive that is no problem since this is only local. You aren't patching any production files either so you won't have to remember "unpatching" them. If you don't want to do any "pre-initialization" you just leave the file empty, which is fine as well. eg Just make an empty
php file somewhere and set "auto_prepend_file = php-file-path" in php.ini and restart your webserver. After that you can just put whatever you want in this file and it will be auto-executed before the control is handed to your script.

I always use an auto_prepend_file for older webprojects. Some of the ancient sites I host are built with register_globals on. What my prepend file does is init essential variables like DOCUMENT_ROOT etc, so that I don't have to modify the actual sites (they aren't mine) Smile And I can still have register_globals off on my server...
View user's profileFind all posts by BlizzSend private messageVisit poster's website
Site Admin

Joined: 13 Jul 2003
Posts: 8342
Reply with quote
see Run->Parameters menu.

GET is supported for all cases, POST only for embedded IE browser.

_________________
The PHP IDE team
View user's profileFind all posts by dmitriSend private messageVisit poster's website
How do I debug a php file with "fake" server vars?
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
All times are GMT - 5 Hours  
Page 1 of 1  

  
  
 Reply to topic