Can PHP effectively determine if JavaScript is enabled for a visitor?

To determine if JavaScript is enabled for a visitor, you can use PHP to check if a specific cookie set by JavaScript is present. JavaScript can set a cookie with a unique value, and then PHP can check for the existence of this cookie to determine if JavaScript is enabled for the visitor.

if(isset($_COOKIE['javascript_enabled'])){
    // JavaScript is enabled
    echo "JavaScript is enabled";
} else {
    // JavaScript is not enabled
    echo "JavaScript is not enabled";
}