Jquery 代码中插入php代码段并展示出来
2017-08-20 17:36
387 查看
<!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 回车
效果图:
<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 回车
效果图:
相关文章推荐
- 做简单的插入图片代码 PHP+Mysql
- 基于JQuery的类似新浪微博展示信息效果的代码
- php 内容插入数据库需要mysql_escape_string处理一下 展示内容时候用htmlentities
- 配置apache和php关联的时候,出现apache无法解析php的情况,以php源码展示出来
- jQuery循环滚动展示代码 可应用到文字和图片上
- 直接插入排序(php代码实现)
- php无限级分类并把末级产品展示出来的思路
- jquery代码中是不能插入el表达式
- PHP接收json 并将接收数据插入数据库的实现代码
- php 在文件指定行插入数据的代码
- 逆序二维数组插入一元素的php代码
- 夺命雷公狗jquery---40在元素头尾部插入元素可alert出来看
- php+jquery+html实现点击不刷新加载更多的实例代码
- jquery随机展示头像代码
- 利用jQuery简单实现产品展示图片左右滚动功能(示例代码)
- Notepad++ 配置 支持jquery、html、css、javascript、php代码提示
- otepad++ 配置 支持jquery、html、css、javascript、php代码提示
- js框架jquery瀑布流图片墙效果代码下载,点击相册图片展示大图
- 仿百度搜索输入框提示JS代码(PHP+MySql数据库版)(基于jquery.autocomplete.js插件)