How do you convert object data to a string?

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
Ahhhk
Forum Newbie
Posts: 4
Joined: Wed May 18, 2005 1:16 pm

How do you convert object data to a string?

Post by Ahhhk »

Hi!

How would I go about putting an object into a string so it can be emailed?

I'm using Pear DB and when there is an error, I want to email the $result.

I can print_r ($result) to output it to the screen. But, how would I get that same print_r output into a string/variable?

$error_dump = var_dump($result) //outputs to the screen as well :/

Thanks for any help!

Ahhhk!
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

Code: Select all

$str = print_r($someVar,true);
:?
Ahhhk
Forum Newbie
Posts: 4
Joined: Wed May 18, 2005 1:16 pm

Post by Ahhhk »

Doh!

Is that it? :0

Thanks feyd!
Post Reply