Try and catch method in php