I have some javascript/jquery code and need to some php into it be the syntax seems to be wrong…
This is what I’m doing:
$.post("myphp.php?something=$phpvariablehere",{ etc....
The result right now is that it’s taking $phpvariablehere as a string and not the value of it.
Anyone know the right syntax?
Use this:
$.post("myphp.php?something=<?php echo $phpvariablehere; ?>",{ etc....It would be worth while understanding the difference between server-side (PHP) and client-side (Javascript) languages, and how/why they interact with each other. you can’t swap between two different languages like you originally attempted – you need to declare a PHP section using these:
<?php ... ?>or you can insert the variable directly by using:
<?= $phpvariablehere ?>