PHP: Added try-catch and public-function.