Safely cast values to float, int, or string in PHP