corillo181 Posted August 20, 2007 Share Posted August 20, 2007 today i decided to try out classes and i can't even get 3 lines to work, anyone care to tell me what I'm doing wrong? thank you. class products{ // } $stock=new products(); print "$stock"; output Catchable fatal error: Object of class products could not be converted to string in C:\wamp\www\Untitled-5.php on line 9 Link to comment https://forums.phpfreaks.com/topic/65861-solved-firstday-class/ Share on other sites More sharing options...
php_tom Posted August 20, 2007 Share Posted August 20, 2007 try this instead: <?php class products{ // } $stock=new products(); var_dump($stock); ?> When doing OO PHP coding, you can't usually just print out an object... Hope this helps. Link to comment https://forums.phpfreaks.com/topic/65861-solved-firstday-class/#findComment-329145 Share on other sites More sharing options...
corillo181 Posted August 20, 2007 Author Share Posted August 20, 2007 i reading from a book and i was fallowing along and they don't say none of that, but i added properties to the class and it works fine. Link to comment https://forums.phpfreaks.com/topic/65861-solved-firstday-class/#findComment-329149 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.