How can a server automatically detect the type of browser accessing a page, such as distinguishing between WML and PHP/HTML pages?

To automatically detect the type of browser accessing a page, you can use the $_SERVER['HTTP_USER_AGENT'] variable in PHP. This variable contains information about the user's browser, which can be used to distinguish between different types of browsers. By analyzing this information, you can determine whether the user is accessing a WML or PHP/HTML page and serve the appropriate content accordingly.

$user_agent = $_SERVER['HTTP_USER_AGENT'];

if (strpos($user_agent, 'WML') !== false) {
    // Serve WML content
    echo "This is a WML browser";
} else {
    // Serve PHP/HTML content
    echo "This is a PHP/HTML browser";
}