At 7/16/06 09:29 AM, elbekko wrote:
Looks like an awful long way to do
echo $statements[array_rand($statements)];
It could be abbreviated quite substanstially if he had not copied and pasted that code directly from a website and actually knew what he was doing. Anywho, it will work so there's no point in me writing out another set of code.
Also, since it's on the client-side, it will be (usually) much faster than a server-side code. So in this case, even if he had PHP, it wouldn't be worth using.
JS is faster and requires less work to acquire a working module in this situation. Although PHP would offer 100% browser compatibility, JS is still a good choice here.
There is one thing I would add to the script though. If the user doesn't have Javascript enabled then they won't see a title. Try this:
<noscript>
document.write('<title>Default Title Here</title>');
</noscript>
Now, if the browser doesn't support Javascript at all, then (in most cases) even the default title will not appear, and you're just SOL.