What are common pitfalls when converting strings to numerical data types in PHP, specifically with JSON decoding?
When converting strings to numerical data types in PHP, a common pitfall is that JSON decoding may return numbers as strings. To avoid this issue, you can use the `JSON_NUMERIC_CHECK` option when decoding JSON data to ensure that numeric values are returned as integers or floats.
$jsonData = '{"number": "42"}';
$data = json_decode($jsonData, true, 512, JSON_NUMERIC_CHECK);
echo $data['number']; // Output: 42 (as an integer)