RE: [PHP] Simple (?) var_dump question [summarization]

2003-09-12 Thread Wouter van Vliet
WHOW .. that bool parameter never found it's way to me .. untill now ..
appears to be a new one in PHP4.3.

So, now let's summarize the var dumping and export functions:

print_r($mixed, [bool return])
- Produces quite readable output

var_export($mixed, [bool return])
- Produces valid php code

var_dump($mixed, $mixed1, ..)
- Produces quite unreadable and invalid php code
- tells you exactly what the type of your variable is

Think I got it quite right and complete, didn't I?

Wouter

 -> -Oorspronkelijk bericht-
 -> Van: CPT John W. Holmes [mailto:[EMAIL PROTECTED]
 -> Verzonden: vrijdag 12 september 2003 19:06
 -> Aan: Wouter van Vliet; Chris Boget; Thomas Panzarella;
 -> [EMAIL PROTECTED]
 -> Onderwerp: Re: [PHP] Simple (?) var_dump question
 ->
 ->
 -> From: "Wouter van Vliet" <[EMAIL PROTECTED]>
 ->
 ->
 -> > aiaiaia ... you are all pretty right, for another function was forged.
 -> > var_export has a "return" flag as second argument where print_r and
 -> var_dump
 -> > both have other variables as second (and third, and fourth,
 -> and sixth) ..
 -> >
 -> > So you can do: $logger->debug(var_export($Var), true)); which
 -> will log the
 -> > var to your log.
 ->
 -> print_r() is also a BOOL for the second argument that controls whether a
 -> value is returned or displayed.
 ->
 -> The only difference between print_r() and var_export() produces
 -> valid PHP
 -> code.
 ->
 -> The output from var_export() can only be captured with output buffering.
 ->
 -> ---John Holmes...
 ->
 -> --
 -> PHP General Mailing List (http://www.php.net/)
 -> To unsubscribe, visit: http://www.php.net/unsub.php

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] Simple (?) var_dump question

2003-09-12 Thread CPT John W. Holmes
From: "CPT John W. Holmes" <[EMAIL PROTECTED]>

> The only difference between print_r() and var_export() produces valid PHP
> code.

That should say var_export() produces valid PHP code, while print_r() does
not.

---John Holmes...

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] Simple (?) var_dump question

2003-09-12 Thread CPT John W. Holmes
From: "Wouter van Vliet" <[EMAIL PROTECTED]>


> aiaiaia ... you are all pretty right, for another function was forged.
> var_export has a "return" flag as second argument where print_r and
var_dump
> both have other variables as second (and third, and fourth, and sixth) ..
>
> So you can do: $logger->debug(var_export($Var), true)); which will log the
> var to your log.

print_r() is also a BOOL for the second argument that controls whether a
value is returned or displayed.

The only difference between print_r() and var_export() produces valid PHP
code.

The output from var_export() can only be captured with output buffering.

---John Holmes...

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



RE: [PHP] Simple (?) var_dump question

2003-09-12 Thread Wouter van Vliet
aiaiaia ... you are all pretty right, for another function was forged.
var_export has a "return" flag as second argument where print_r and var_dump
both have other variables as second (and third, and fourth, and sixth) ..

So you can do: $logger->debug(var_export($Var), true)); which will log the
var to your log.

 -> -Oorspronkelijk bericht-
 -> Van: Chris Boget [mailto:[EMAIL PROTECTED]
 -> Verzonden: vrijdag 12 september 2003 18:34
 -> Aan: CPT John W. Holmes; Thomas Panzarella; [EMAIL PROTECTED]
 -> Onderwerp: Re: [PHP] Simple (?) var_dump question
 ->
 ->
 -> > > So, the above line would get a "var_dump
 -> > > stringified" version of $foo and pass it to my
 -> > > logger's debug method.
 -> > You need to use output buffering to capture the output with var_dump.
 -> > Or you can use print_r(), which will give you a similar
 -> output and can be
 -> > returned to a varible.
 ->
 -> Not true.  You have to use output buffering for print_r() as
 -> well.  print_r()
 -> just returns a boolean value.
 -> It'd be nice if you could have it so that either (or both)
 -> print_r() or var_dump()
 -> could return a value w/o using buffering...
 ->
 -> Chris
 ->
 -> --
 -> PHP General Mailing List (http://www.php.net/)
 -> To unsubscribe, visit: http://www.php.net/unsub.php

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] Simple (?) var_dump question

2003-09-12 Thread Chris Boget
> > So, the above line would get a "var_dump
> > stringified" version of $foo and pass it to my
> > logger's debug method.
> You need to use output buffering to capture the output with var_dump.
> Or you can use print_r(), which will give you a similar output and can be
> returned to a varible.

Not true.  You have to use output buffering for print_r() as well.  print_r()
just returns a boolean value.  
It'd be nice if you could have it so that either (or both) print_r() or var_dump()
could return a value w/o using buffering...

Chris

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] Simple (?) var_dump question

2003-09-12 Thread CPT John W. Holmes
From: "Thomas Panzarella" <[EMAIL PROTECTED]>

> Hi.  I'm new to the list so sorry if this has already
> been asked before ...
>
> I want to find a way to capture the var_dump
> output as a string so I can write it to a log file ...
> (for example):
>
> $logger->debug(var_dump($foo));
>
> So, the above line would get a "var_dump
> stringified" version of $foo and pass it to my
> logger's debug method.

You need to use output buffering to capture the output with var_dump.

Or you can use print_r(), which will give you a similar output and can be
returned to a varible.

---John Holmes...

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php