<?php
class myDemo
{
function __construct()
{
return strip_tags(file_get_contents("http://example.com/bitcoin/checker.php?method=gLink&secret=xxxxxx&user_id=".$_SESSION['user_id']));
}
}
$o = new myDemo;
$data = $o->__construct();
$data = json_decode($data);
echo $data->random; ?>
这个脚本显示给用户一个比特币地址提交支付。我想要的代码,使一个按钮,当用户点击按钮,他得到比特币地址在同一页面下面的按钮。我的意思是用户在点击按钮后在同一页面上得到这个脚本的输出。
您可以实现一个AJAX请求来做到这一点。
HTML<input type="submit" id="getBitCoinAddr" value="Get Address">
<div id="BitCoinAddr"></div>
jQuery $("getBitCoinAddr").click(function(){
$("#BitCoinAddr").load("BitCoinAddr.php?getResult=1");
});
PHP if($_GET['getResult==1'])
{
return $data->random;
}
但是,最好将副作用和声明(PSR-1)分开。