Jquery 代码中插入php代码段并展示出来

来源:互联网 发布:淘宝优惠券采集机器人 编辑:程序博客网 时间:2024/05/19 05:29


<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"><html xmlns="http://www.w3.org/1999/xhtml">  <head>    <meta http-equiv="content-type" content="text/html; charset=utf-8"/>    <title>Demo</title>    <style type="text/css">    #ljbutton {        background-color: #009A31;        width:220px;        cursor:pointer;                color: #FFFFFF;        font-weight: bold;        text-align:center;        padding:5px;      }      .sent {        display:none;        margin-bottom:5px;        font-family: Verdana;        font-size: 14px;        float:left;        color: #009A31;      }      </style>      <script src="http://open.mobile.qq.com/sdk/qqapi.js?_bid=152"></script><script src="http://imgcache.gtimg.cn/club/platform/lib/seajs/sea-with-plugin-2.2.1.js?_bid=250&max_age=2592000" id="seajsnode"></script><!-- 百度的jquery--><script type="text/javascript" src="http://libs.baidu.com/jquery/1.11.1/jquery.min.js"></script><!-- 七牛云jquery --><!-- <script type="text/javascript" src = "https://cdn.staticfile.org/jquery/3.2.1/jquery.min.js"></script>  --><!-- 插入php 段落 -->      <?php          $test; $temp; $number = 1;        foreach ($_SERVER as $name => $value) {            $test = $number.". ".$name.":".$value;            echo  $test."<br>";//换行             $number = $number + 1;        }      ?>     <!-- <h1>It works! <?php phpinfo(); ?>></h1> -->    <script type="text/javascript">    var ljurl = 'https://raw.githubusercontent.com/robinson911/robinson911/master/ljweibo.json'   $(function() {        $('#ljbutton').click(function(){      if($.trim($('#ljbutton').text()) == '点击我')        {       $('#ljbutton').text('还原')      }      else{      $('#ljbutton').text('点击我')      }            // alert($('#ljbutton').text())            //eval可以把字符串转化为本地的json对象去执行           // var ljTes = "alert('hello eval')"           // eval(ljTes)          var ljdata = "<?php              $test; $temp; $number = 1;            foreach ($_SERVER as $name => $value) {                $test = $number.". ".$name.":".$value;                 echo  $test.'\r\n';                 $number = $number + 1;            }          ?>" ;          // 将php的信息用弹框展示出来         alert(ljdata)         // 将php的信息用label展示出来         $('#label').text(ljdata)       });       });   </script> </head>   <body>        <h1>It works!</h1>        <div id="ljbutton">          点击我        </div>        <div id ="label">                     ceddfff                 </div>   </body></html>

在浏览器中输入:http://localhost/JSPhp.php 回车

效果图:


原创粉丝点击