Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Safe __toString method
<?php
/**
* String representation of this object
* @return string
*/
public function __toString()
{
try {
return (string) $this->name;
} catch (Exception $exception) {
return '';
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.