To use the PHP built-in function intval ( to convert a string to an integer, pass the string as an argument to the function. The integer value corresponding to the string content will be returned by the function. We’ll use the intval () function to transform a string having integer content into an integer in the following example.