+ 1

$ to declare variable in php & $ used as shortcut in JQuery, both in the same file, so the question is don't they get conflict?

All in all the code works fine.

1st Aug 2020, 5:58 PM
Shweta Mahajan
Shweta Mahajan - avatar
4 Réponses
+ 3
As the other answers suggest, PHP and JavaScript do not share the same namespace even if they coexist in a single file. What you actually should be worried about is readability and separation of concerns. Also note that if you include 2 different frameworks using <script> tags that use the same $ sign, there would be conflict and you may have to explicitly refer to 'jquery' instead of '
#x27;
1st Aug 2020, 10:09 PM
Ore
Ore - avatar
+ 3
There is no conflict because of the tags: <script> for JQuery <?php for PHP
1st Aug 2020, 6:09 PM
Gabriel Ilie
Gabriel Ilie - avatar
+ 3
Php works inside <?php ...... ?> jQuery works inside <script> How it is possible to conflict both for $
1st Aug 2020, 6:11 PM
Divya Mohan
Divya Mohan - avatar
+ 1
There is no conflict because JavaScript code goes between the <script> and </script> tags, and PHP code goes between the <?php and ?> tags. <script> // here, $ is a shortcut for jQuery </script> <?php /* here, $ is the first character of a PHP variable */ ?>
4th Aug 2020, 11:56 PM
SapphireBlue
SapphireBlue - avatar