reedjasonf
Solid State Member
- Messages
- 9
I have 2 different files: vars.php and functions.js.
Inside my vars.php I have declared a few variables:
example:
$var1 = "This is a string";
$var2 = 50;
$var['array'] = "This is an array";
I'd like to pass these variables to my functions.js so that if I ever need to change the variables I only need to do that in the php file containing all my variables.
I've looked at other forums and they say I should be able to do this:
var jsvar = "<?php echo $var1;?>";
... but when I do this jsvar becomes literally "<?php echo $var1;?>" instead of "This is a string" like I want it to. Anyone know what my problem is?
Inside my vars.php I have declared a few variables:
example:
$var1 = "This is a string";
$var2 = 50;
$var['array'] = "This is an array";
I'd like to pass these variables to my functions.js so that if I ever need to change the variables I only need to do that in the php file containing all my variables.
I've looked at other forums and they say I should be able to do this:
var jsvar = "<?php echo $var1;?>";
... but when I do this jsvar becomes literally "<?php echo $var1;?>" instead of "This is a string" like I want it to. Anyone know what my problem is?