I have a JS file linked with <script src="...">, which I want to use PHP variables in. Is there any way of doing this? I tried a simple test:
<?php echo "alert('hello world!')" ?>Which gave me a syntax error (the php code was not executed).
Is there something like eval(); that I can use? (Note: I want the file to remain external, it's not the shortest of files)
04-19-2004, 02:54 AM
04-19-2004, 03:38 AM
echo "<script>alert('hello world');</script>";
04-19-2004, 10:29 PM
I think dswimboy is right. If you don't want to rename your file, you'll have to add the .js extension to your server to be parsed as a PHP file.
04-19-2004, 10:52 PM
No, I tested it all you got to do is:
echo ("<script src = 'wahteveritis.js'></script>")
Or the tested thing:
echo ("<script>alert('Hello World')</script>")
04-19-2004, 11:28 PM
in it. Presumes that you're running this on Apache, and have permissions to use .htaccess files. And of course external.js must be the name of the JS file in question.