Exception::getTraceAsString — Gets the stack trace as a string. So use $e->getTraceAsString() i.e.:
<?php
try {
throw new Exception("Some error message");
} catch(Exception $e) {
echo "The exception was created from: \n\r" . $e->getTraceAsString();
}
?>