The public part of the PHP page is converted to JS document.write (); And is wrapped by an anonymous function

Source: Internet
Author: User

The common part of the page loads the generated JS into the desired location in JavaScript document.write () Footer.js put into the body bottom introduced ... <script src= "Js/footer.js" ></ Script></body>--------------------------------------Php.exe Add the folder to the PATH environment variable, enter PHP at the command line Footer.html--------------------------------------
<?php$handle = fopen ("footer.html", "R");   Enter the HTML file $dest = fopen ("Footer.js", "w");         Output JS file 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);}? >

  

Input file:

<div id= "Footer" ><div class= "container text-center" ><div class= "copyright" >copyright?2017~2020 <a href= "http://www.tsinghuadtv.com/" target= "_blank" > Ling Software </a> Technical Support <a href= "/http/ www.miitbeian.gov.cn "target=" _blank "> Beijing ICP No. 13,010,031th </a></div></div></div>

  

Output file:
(function () {document.write ("<div id=\" Footer\ ">");d ocument.write ("<div class=\" Container text-center\ " > ");d ocument.write (" <div class=\ "copyright\" >copyright?2017~2020 ");d ocument.write (" <a href=\ "/http/ Www.tsinghuadtv.com/\ "target=\" _blank\ "> Ling Software </a> Technical Support");d ocument.write ("<a href=\"/http/ Www.miitbeian.gov.cn\ "target=\" _blank\ "> Beijing ICP No. 13,010,031th </a>");d ocument.write ("</div>"); document.write ("</div>");d ocument.write ("</div>");}). Call ();

  

The public part of the PHP page is converted to JS document.write (); And is wrapped by an anonymous function

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.