如何通过PHP检查JavaScript是否处于活动状态?

Is it possible to do checking and verification of JavaScript state in a browser ?

At the top of your index.php you could do something like

<script type="text/javascript">
    window.location = '/index_with_js.php'
</script>

So, if the browser had JS enabled, it would be redirected to a special index page, which could in turn set a session variable, e.g. $_SESSION['has_js'] = true;

If the browser doesn't have JS enabled, the page won't be directed, so $_SESSION['has_js'] won't ever be set.

No, not reliably. But it is possible to respond with something (on the client) if Javascript is not available using noscript:

<noscript>Your browser does not support JavaScript!</noscript>

Is there any reason you need to do this via PHP, instead of displaying a message in the browser using the NOSCRIPT tag?

That's the wrong way to do it. PHP should be outputting markup that works with JavaScript off, and you should be enhancing that markup with JavaScript. I suggest you read up on progressive enhancement.