Monday, July 02, 2007

Javascript alert in PHP

How do you put javascript in PHP code? A friend of mine who is taking a web course asked me, well, this is indeed a basic question. But his instructor "forces" him to use alert method to output the session value, so it took quite a while to figure out how to do this.

Basically his assignment is echo number of visitors by using session and alert the value. Here is how?

$_SESSION['visitors'] = $_SESSION['visitors'] + 1;

echo "";
Feels too basic? Yup,it is... But it does annoys beginners for a few days,esp when his/her head prefer this evil javascript...

No comments: