FUDforum
Fast Uncompromising Discussions. FUDforum will get your users talking.

Home » Imported messages » comp.lang.php » Names of URL Parameters
Show: Today's Messages :: Polls :: Message Navigator
Return to the default flat view Create a new topic Submit Reply
Re: Names of URL Parameters [message #175462 is a reply to message #175455] Thu, 29 September 2011 13:15 Go to previous message
sheldonlg is currently offline  sheldonlg
Messages: 166
Registered: September 2010
Karma:
Senior Member
On 9/28/2011 2:46 PM, tamouse wrote:
> Since the question seems directed to debugging, you should know about two functions: print_r and var_dump:
>
> http://us2.php.net/manual/en/function.print-r.php
> http://us2.php.net/manual/en/function.var-dump.php
>
> In both of these cases, the standard behaviour is to dump the variable structure straight to the standard output (most likely your browser window/tab). This can be problematic for a few reasons, and can be a security risk if you're not careful.
>
> print_r has a second paramter, which if set to TRUE, will return it's output as a string, which you can sanitize before sending to output thus:
>
> echo "<pre>" . htmlentities(print_r($var,TRUE)) ."</pre>" . PHP_EOL;
>
> This sort of thing will prove invaluable in debugging php code for the newbie.
>
> If you're doing a fair bit of this, you might want to set up a function for debugging, and use a global to turn on/off debugging. Lots of these exist already, some very sophisticated, some very simple.
>
> Extremely simple:
>
> function dbg($var)
> {
> if ($GLOBALS['DEBUG'])
> {
> echo "<pre>".print_r($var,TRUE)."</pre>".PHP_EOL;
> }
> }
>
> And you can set $GLOBALS['DEBUG'] in a number of ways, such as in a common configuration file that is included in your application, or by introducing a DEBUG parameter in the $_REQUEST hash.
>
> Some people (*cough*) go so far as to write a debugger class with all sorts of fancy bells and whistles, such as including the file, function, and line number where the debugging call is made, among others.

I would use $_SESSION['DEBUG'] instead.

--
Shelly
[Message index]
 
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Previous Topic: best editor
Next Topic: discussing LeBron 8 PS
Goto Forum:
  

-=] Back to Top [=-
[ Syndicate this forum (XML) ] [ RSS ]

Current Time: Wed Nov 27 19:42:01 GMT 2024

Total time taken to generate the page: 0.04159 seconds