标签:error: targe 匿名 命令行 tar container html 位置 eof
<?php $handle = fopen("footer.html", "r"); // 输入html文件 $dest = fopen("footer.js", "w"); // 输出js文件 if ($handle) { fwrite($dest, "(function() {\n"); while (($buffer = fgets($handle, 4096)) !== false) { $s = addslashes($buffer); $line = "\tdocument.write(\"" . rtrim($s, "\r\n") . "\");\n"; fwrite($dest, $line); } fwrite($dest, "}).call();"); if (!feof($handle)) { echo "Error: unexpected fgets() fail\n"; } fclose($handle); fclose($dest); } ?>
输入的文件:
<div id="footer"> <div class="container text-center"> <div class="copyright">Copyright?2017~2020 <a href="http://www.tsinghuadtv.com/" target="_blank">凌讯软件</a> 技术支持 <a href="http://www.miitbeian.gov.cn" target="_blank">京ICP备13010031号</a> </div> </div> </div>
(function() { document.write("<div id=\"footer\">"); document.write(" <div class=\"container text-center\">"); document.write(" <div class=\"copyright\">Copyright?2017~2020 "); document.write(" <a href=\"http://www.tsinghuadtv.com/\" target=\"_blank\">凌讯软件</a> 技术支持"); document.write(" <a href=\"http://www.miitbeian.gov.cn\" target=\"_blank\">京ICP备13010031号</a>"); document.write(" </div>"); document.write(" </div>"); document.write("</div>"); }).call();
php 页面公共部分 转化为js document.write(); 并由匿名函数包裹
标签:error: targe 匿名 命令行 tar container html 位置 eof
原文地址:https://www.cnblogs.com/mingzhanghui/p/9168384.html