Is this correct? If not what is the correct syntax
I am new to php hence trying to learn.
It will not work because php is a server-side pre-processor that cannot know anything about the user's browser other than what is provided in the browser's original request, which includes nothing about its current scripting capability.
Basically, if you want to have rich content beyond the simplistic noscript
tags -- they can only add non-scripted content, not hide scripted content -- you have to:
div
or span
tags with class="nocript"
.div
or span
tags with class="script"
.div.noscript{display:block}
, span.noscript{display:inline}
, .script{display:none}
.class="noscript"
with element.style.display='none'
, show each div
with class="script"
with element.style.display='block'
and show each span
with class="script"
with element.style.display='inline'
.You also have to consider that a browser is an especially hostile environment to be programming into, as the user, or any plugins, can do anything, like disable javascript, at any time. Therefore, you have to double-check everything that the browser sends, whether by form or AJAX, in your PHP code to make sure it is complete and not corrupt.