What are some potential pitfalls when converting strings to integers in PHP?
One potential pitfall when converting strings to integers in PHP is that the conversion may result in unexpected behavior if the string contains non-numeric characters. To avoid this issue, you can use the intval() function in PHP, which will convert the string to an integer while ignoring any non-numeric characters.
$string = "123abc";
$integer = intval($string);
echo $integer; // Output: 123