Welcome to collectivesolver - Programming & Software Q&A with code examples. A website with trusted programming answers. All programs are tested and work.

Contact: aviboots(AT)netvision.net.il

Buy a domain name - Register cheap domain names from $0.99 - Namecheap

Scalable Hosting That Grows With You

Secure & Reliable Web Hosting, Free Domain, Free SSL, 1-Click WordPress Install, Expert 24/7 Support

Semrush - keyword research tool

Boost your online presence with premium web hosting and servers

Disclosure: My content contains affiliate links.

39,890 questions

51,817 answers

573 users

How to output an object for debugging in PHP

6 Answers

0 votes
$o = new stdClass();
$o->value = 'PHP Programming';
$o->test = 100;

echo "<pre>";
print_r($o);
echo "</pre>";

/*
run: 
 
stdClass Object
(
    [value] => PHP Programming
    [test] => 100
)
 
*/

 



answered Jul 26, 2017 by avibootz
0 votes
$o = new stdClass();
$o->value = 'PHP Programming';
$o->test = 100;
 
echo '<pre>' . print_r($o, true) . '</pre>';

/*
run: 
 
stdClass Object
(
    [value] => PHP Programming
    [test] => 100
)
 
*/

 



answered Jul 26, 2017 by avibootz
0 votes
$o = new stdClass();
$o->value = 'PHP Programming';
$o->test = 100;
 
header('Content-Type: text/plain; charset=utf-8');
print_r($o);

/*
run: 
 
stdClass Object
(
    [value] => PHP Programming
    [test] => 100
)
 
*/

 



answered Jul 26, 2017 by avibootz
0 votes
$o = new stdClass();
$o->value = 'PHP Programming';
$o->test = 100;
 
var_dump($o); 

/*
run: 
 
object(stdClass)#1 (2) { ["value"]=> string(15) "PHP Programming" ["test"]=> int(100) }
 
*/

 



answered Jul 26, 2017 by avibootz
0 votes
$o = new stdClass();
$o->value = 'PHP Programming';
$o->test = 100;
 
var_export($o); 

/*
run: 
 
stdClass::__set_state(array( 'value' => 'PHP Programming', 'test' => 100, ))
 
*/

 



answered Jul 26, 2017 by avibootz
0 votes
$o = new stdClass();
$o->value = 'PHP Programming';
$o->test = 100;
 
echo var_export($o, true); 

/*
run: 
 
stdClass::__set_state(array( 'value' => 'PHP Programming', 'test' => 100, ))
 
*/

 



answered Jul 26, 2017 by avibootz

Related questions

6 answers 381 views
381 views asked Jul 26, 2017 by avibootz
4 answers 275 views
275 views asked Sep 2, 2017 by avibootz
1 answer 141 views
141 views asked Jul 29, 2017 by avibootz
1 answer 159 views
...