I'm assuming you called your function in a manner of the form:
$data = new stdClass();
test_3($data);
This fails then as you end up in your else
statement, and you can't concatenate a stdClass() to a string (in this case 'World').
A bit more review suggests that your actual function call is test_3($data->name)
, and $data->name
is likely of stdClass() instead of a string that can be concatenated with 'World'.
For reference, if you have an error, it'd be helpful to provide the actual line number the error is corresponding to . . . I'm guessing the error is due to the concat, since that's the only place where I see a stdClass() to string conversion would be necessary.