문제

I was looking at thenextweb's team page and found that inside < head>, they are including an external php file within the < script> tag. Is this a good practice ? And what might be the purpose of doing this ?

URL: http://thenextweb.com/about/team/

Code:

<script type="text/javascript" src="/about/php/scriptsData.php"></script>
도움이 되었습니까?

해결책

JavaScript files need not have the .js extension. Sometimes you need to generate JavaScript dynamically and you end up with a .php file. For example, for placing markers in a Google map with the API, I generated the JavaScript file with php (fetching the marker locations from a database) rather than using some sort of AJAX. There's nothing wrong with it.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top