I hope someone is able to help me. The problem is the following one: 1)I have module in which a assign the variable in order to send to the template file php.tpl
<?php ... $testvar="Hello from alex!"; $variables['testvar'] = $testvar; ... ?>
This variable can be shown in the php.tpl file like
<?php print $testvar?>
2)I have separated .js file How can i get access to this varuiable inside .js file?
I know how it'll be if .js file is inside .php.tpl:
The problem is how to do the same if these two files .js and .php.tpl are separated?
var myVar = <?php echo json_encode($testvar) ?>;which will take care of any such issues for you, regardless of the PHP var's data-type/content.