Welcome to the Treehouse Community
The Treehouse Community is a meeting place for developers, designers, and programmers of all backgrounds and skill levels to get support. Collaborate here on code errors or bugs that you need feedback on, or asking for an extra set of eyes on your latest project. Join thousands of Treehouse students and alumni in the community today. (Note: Only Treehouse students can comment or ask questions, but non-students are welcome to browse our conversations.)
Looking to learn something new?
Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and a supportive community. Start your free trial today.

jamesjones21
9,260 PointsRecoverable fatal error: Object of class could not be converted to string
HI Guys,
I have a class which has two static functions:
class Render
{
public static function listCustomerOrder($order)
{
$output2 = "";
$output2 .= $order->getCustomerName();
$output2 .= $order->GetItemQuantity();
return $output2;
}
public static function displayCustomerOrder ($shoppingCart) //
{
$output ="";
$output .= self::listCustomerOrder($shoppingCart->getCustomerName());
return $output;
}
}
when calling the function render like so:
echo new Render();
It provides me with object of class could not be converted to string.
any ideas?
cheers,
James
1 Answer

jamesjones21
9,260 Pointsthanks for the input, I resolved the issue, I had to have a __construct and a __toString method added :) OOP is hard enough to grasp but getting there slightly.
regards,
James
Nedim Becirovic
9,394 PointsNedim Becirovic
9,394 PointsYou can echo only string values. If you want to see any other value use var_dump().