I found this script somewhere on a web page which has external php file linked in script tag. I googled it but nothing found useful. can anyone make me understand about this?
<script type="text/javascript" src="file.php"></script>
Below is the content of file.php
Bootstrapper._serverTime = '2015-08-01 11:50:50';
Bootstrapper._clientIP = '103.39.117.145';
Bootstrapper.callOnPageSpecificCompletion();
Bootstrapper.setPageSpecificDataDefinitionIds([])
Yes, it's not an unknown practice, many CMS's as well as projects use an "endpoint" or a "script" dedicated to handle the frontend resources.
They can perform tasks such as minification of resources into one single chunk, or just plain concatenation of resource files into one.
As long as anything (script or endpoint) outputs javascript, or in this case echo
's javascript, it can be used referred in a script tag.
Note - This requires the script or endpoint to handle output headers as well, which is commonly done by sending in a
Content-Type
header along the responseIn PHP it's usually done using
header('Content-Type: application/javascript');
在我看来,在给定的情况下, File.php
可以简单地动态生成javascript
代码(例如,从数据库中加载一些JS等)。
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.