-1

Hi i'm begineer in PHP/JS and i have small question, how can PHP read values of variables in JavaScript?

i have this JS code where i have values

<script type="text/javascript">

function test(tag) 
{
var output = tag; 
<?php $tags ?> = output; //i tested, but not works
}
</script>

there's php read code

<?php
echo "$tags";
?>

i'm in end with this, Thanks for answers!

Powering
  • 39
  • 1
  • 4
  • 1
    it won't , php will execute in web server and response will sends to browsers. you can use ajax functionality for this scienario – Naisa purushotham Jul 07 '16 at 17:41
  • No, why you need it? –  Jul 07 '16 at 17:42
  • Outside of the function, try this: alert(''); and make sure it's outputting what it should. – awl19 Jul 07 '16 at 17:43
  • @Naisapurushotham You can use PHP in JQuery if it's inline in the HTML rather than in its own file. Although, I wouldn't suggest people go this route. It's rather clunky and seems unnecessary. – awl19 Jul 07 '16 at 17:47

1 Answers1

2
<?php $tags ?> = output; //i tested, but not works

should be

<?php echo $tags ?> = output;
Tom Morison
  • 564
  • 1
  • 8
  • 26