Can I use php in javascript?

后端 未结 7 452
萌比男神i
萌比男神i 2021-01-25 23:49

Begginer\'s question.

Can I use PHP in javascript?

For example in jquery,

...
...
triggers.eq(1).post(\'

        
相关标签:
7条回答
  • 2021-01-26 00:36

    No, you cannot use PHP within JavaScript. Think about it this way: you need a PHP interpreter/runtime to execute the PHP, and browsers do not contain this. Based on your code snippet above, you could instead send an ajax call to a PHP script on the server.

    I suppose you could pass PHP code to a server-side script and interpret/execute it, but you'd still need ajax or a full GET/POST request, and it would never be a good thing to do because of how easy it would be for malicious code injection.

    0 讨论(0)
提交回复
热议问题