I have a PHP file that contains a javascript function. This function takes “user” as a parameter. How can I include this parameter in embedded PHP?
$("#items-table").html("<p><?php echo(hello " + user + "); ?></p>")
The error I get is:
Parse error: syntax error, unexpected T_CONSTANT_ENCAPSED_STRING
Must I result to appending to the html in separate chunks?
PHP is a server-side language, and JavaScript is client side. The only way to achieve what you are trying to accomplish is to run the page and first have PHP process what it needs, then send the page to the client, and have the client process what he or she needs.