On Mon, Feb 20, 2006 at 06:29:12PM +1030, Tim Burgan wrote: > Is is possible to make an external Javascript with PHP. > > Am I doing this correcT? > > <?php > > header("Content-Type: text/javascript"); > > $text = "Hello World"; > > echo "alert('".$text."');"; > > ?> This looks perfectly fine. There are a few things you have to be careful with: - php strings can handle line endings, consider if you have: $text = "Hello\nWorld"; echo alert('". $text ."'); You will end up with a javscript error. - A typical javascript file that resides on on a webserver will only be requested once from the webserver (pending cache settings) so resources for a page load will be minimal. If you have a php script output javascript, the browser will request the file on each request. Curt. -- cat .signature: No such file or directory -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php