Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

what does it mean when we echo javascript

I am not able to figure out what we really mean when we echo javascript. Does it mean; the function inside script will execute inevitably? I mean, will it execute with out even being called? I've seen long scripts that seem to include a complete page inside an echo statement.

echo "<script type='text/javascript'>
$(function(){
blah blah blah
});
</script>";
like image 479
harry Avatar asked Mar 14 '26 05:03

harry


1 Answers

It means exactly the same thing as when we echo HTML: that text will be sent to the browser. What the browser does with it is independent of what PHP does.

like image 118
Ignacio Vazquez-Abrams Avatar answered Mar 16 '26 19:03

Ignacio Vazquez-Abrams



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!