What are the advantages to putting your Javascript in a .php file?

前端 未结 7 2478
独厮守ぢ
独厮守ぢ 2021-02-15 12:40

I occasionally come across pages where some Javascript is included via a PHP file:


  
    

        
7条回答
  •  别那么骄傲
    2021-02-15 13:25

    Advantage (not PHP specific - I used this technique in EmbPerl and JSP) would be the ability to dynamically generate or tweak/customize the JavaScript code on the server side.

    An example usage would be population of an array based on the contents of a DB table. Or application of localization techniques.

提交回复
热议问题