CHANGED type casting to return numeric value if string is numeric value and value is lower than maximum integer values in php and javascript