-------------------------------------------------------------------------------- such as in js file j.js I wanna evalue js variable to a php Constant varialble defined in config.php so I need include the config.php how to do this?
I think I know what your TRYING to do but please explain in English so I can be sure what you wan to do... Explain by leaving out: "wanna", "evalue"(which is not a word), "variable"(which you spelled wrong), "constant" and "defined" These are the thing I can not make out because they are causing a loop to nothing. Just tell us what it is you really want...
you need to get your web server to parse javascript files as php... or... just make your js file a php file... <script type="text/javascript" src="myjavascript.php"> PHP: and then inside myjavascript.php: var jsVar = "Here is a regular javascript variable"; var phpVar = "<?php echo "Here is a js variable passed from php"; ?>"; alert(jsVar+phpVar); PHP:
sorry , such as I have a php file config.php <?php $Host_php="http://www.a.com"; $Port_php="8899"; ?> and have a javascript file run.js <?php include "config.php" var host_js = "<?php echo $Host_php?>"; ?> but the host_js get an empty value instead of the value of $Host_php can you help ?