Coding for both js and non-js browsers

I’m currently modifying a php controlled website and wish to distinguish between javascript and non-javascript browsers in order to decide which pages to display.
I have a single php controller script which “includes” a number of html pages. I want to ensure that I cater for both javascript and non-javascript browsers (so functionality is the same, only the javascript pages have a far better look and feel to them).

Therefore I would like to code something along the lines of :

if (javascript_browser=='true')
{
 include './javascript_page1.html.php';
 exit();
}
else
{
 include '.non_javascript_page1.html.php';
 exit();   
}

can anyone advise on the best way to achieve this please…

Look into techniques of “Progressive Enhancement”, where your basic non-js site is a) navigable b) readable and makes sense then you progressively add JS to enhance the experience.

All client side dependencies such as is JS turned on happen on the client, PHP has already done its job and sent the stream of data to the client. So forget that idea now.