doujiao2000 2017-07-24 22:09
浏览 54
已采纳

php echo添加“0”); </ script>“到输出的结尾

I run a local server I am working on and php echo appears to be freaking out. This is the error:

echo "<script>console.log('test');</script>";

yields

<script>console.log('test');</script>;0')</script>

when I "view page source" of the webpage. In the page itself, this shows up as just 0'); and the console.log() appears to be working just fine. If I change one of these to remove all javascript and just do something like

echo "testing";

what shows up is:

testing0');</script>

when I write a new echo it works fine, when I have tried making new pages, they also work fine, when I view it in safari (I regularly use chrome) this problem persists. This problem occurs each time I echo a script, but when echoing something else it behaves normally. Only if I change an existing echo to plain text does it still append the ;0')</script>, when I write a new echo that writes a script it works just fine.

If I add die(); after any echo statements, that one (and that one only) lacks the ;0')</script> all those above it still have it at the end.

What the heck did I do to cause this?

info: I am using the default apache install on mac and php version 5.5.36. Feel free to ask me clarifying questions and if need be I can post the full php file on github.

Thanks in advance,

Lewis

Edited for clarity.

  • 写回答

1条回答 默认 最新

  • duanliyi5997 2017-07-24 23:18
    关注

    Well I feel pretty dumb, I was indeed spitting out ;0')</script> after each and every echo, because all of my console.log()s came in pairs and the second one always looked something like this:

    echo "
    <script type=\"text/javascript\">
        console.debug('".'  '+gettype($sql_peices)."');
    </script>";
    

    and the plus in there was causing the issue, I should have:

    echo "
    <script type=\"text/javascript\">
        console.debug('".'  '.gettype($sql_peices)."');
    </script>";
    

    with a period. I have no idea when or how I put that in there, but now everything is working perfectly.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥100 支付宝网页转账系统不识别账号
  • ¥15 基于单片机的靶位控制系统
  • ¥15 AT89C51控制8位八段数码管显示时钟。
  • ¥15 真我手机蓝牙传输进度消息被关闭了,怎么打开?(关键词-消息通知)
  • ¥15 下图接收小电路,谁知道原理
  • ¥15 装 pytorch 的时候出了好多问题,遇到这种情况怎么处理?
  • ¥20 IOS游览器某宝手机网页版自动立即购买JavaScript脚本
  • ¥15 手机接入宽带网线,如何释放宽带全部速度
  • ¥30 关于#r语言#的问题:如何对R语言中mfgarch包中构建的garch-midas模型进行样本内长期波动率预测和样本外长期波动率预测
  • ¥15 ETLCloud 处理json多层级问题