How can the locale be set globally in PHP to ensure consistent behavior for functions like strtoupper?

When working with functions like strtoupper in PHP, it's important to set the locale globally to ensure consistent behavior across different environments. This can be achieved by using the setlocale function in PHP to set the desired locale for string conversion functions.

setlocale(LC_ALL, 'en_US.UTF-8');
$text = 'hello world';
echo strtoupper($text);