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,859 questions

51,780 answers

573 users

How to output an object in PHP

4 Answers

0 votes
$object = new stdClass();
$object->text = 'php';
$object->version = '7.2';

print_r($object);


/*
run: 
 
stdClass Object ( [text] => php [version] => 7.2 )
 
*/

 



answered Sep 2, 2017 by avibootz
0 votes
$object = new stdClass();
$object->text = 'php';
$object->version = '7.2';

var_dump($object);


/*
run: 
 
object(stdClass)#1 (2) { ["text"]=> string(3) "php" ["version"]=> string(3) "7.2" }
 
*/

 



answered Sep 2, 2017 by avibootz
0 votes
function print_o($o)
{
    echo '<pre>';
    print_r($o);
    echo  '</pre>';
}

$object = new stdClass();
$object->text = 'php';
$object->version = '7.2';

print_o($object);


/*
run: 
 
stdClass Object
(
    [text] => php
    [version] => 7.2
)
 
*/

 



answered Sep 2, 2017 by avibootz
0 votes
$object = new stdClass();
$object->text = 'php';
$object->version = '7.2';

var_export($object);


/*
run: 
 
stdClass::__set_state(array( 'text' => 'php', 'version' => '7.2', ))
 
*/

 



answered Sep 2, 2017 by avibootz

Related questions

6 answers 359 views
6 answers 379 views
379 views asked Jul 26, 2017 by avibootz
1 answer 63 views
1 answer 78 views
78 views asked Dec 4, 2022 by avibootz
2 answers 321 views
...