function move(){
var move= <?php echo $config['root'];?>
window.location.href=""+move+"sf/" ;
}
I have config.php and all the root variable is defined in it, I want to move the user on click to that URL,
- Problem is that I can't access the variable from config.php
- Its not good to create an index.js file as well.
- As the code moves between Prod, QA and Dev so the URL changes for each environment, I want that I only change at one point and dont have to make changes at all code. The above code is also not working .
What JS variable are you trying to access in PHP? It looks to me like you're trying to use PHP in your JS, not the other way around.
I think you just need to put quotes around your PHP output like this:
Then you can simply do this: