I want to echo the variable when I use test(); fuction. I meanwhen I use the variable with this function like test(john) , how to use it in that php snippet. Anyone knows ?

<script type="text/javascript">
function test(){
document.getElementById("php_code").innerHTML="
<?php echo "hello"; ?>
";
}
</script>

Why do you need php in order to display the value of the variable? You could simply use it.

<script type="text/javascript">
function test(aVariable){
  document.getElementById("php_code").innerHTML=aVariable
  // you could use aVariable.toString() if you want to but may not get different result
}
</script>
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.