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 Quote 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. Quote 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. Quote Link to comment https://forums.phpfreaks.com/topic/65861-solved-firstday-class/#findComment-329149 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.