服务器端函数
function order_kb(){
$expressodd[0]['odd']='560860393435';
$expressoddjson = json_encode($expressodd);
return $expressoddjson;
}
客户端请求php文件
$post_data = array () ;
$url = 'http://www.test.com/index.php?m=user&a=order_kb' ;
$o = "" ;
foreach ($post_data as $k=>$v)
{
$o.="$k=".urlencode($v)."&";
}
$data=substr($o,0,-1);
$ch = curl_init();
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_HEADER,0);
curl_setopt($ch, CURLOPT_URL,$url);
curl_setopt($ch, CURLOPT_POSTFIELDS, $data);
$result = curl_exec($ch);
curl_close($curl);
print_r(json_decode($result,TRUE));
print_r(json_decode($result,TRUE)[0]['odd']);//打印出来看结果
?>
为什么得不到返回值?打印出来是空白的页面
回复讨论(解决方案)
这个网站在第一次访问时会执行如下 js 代码
function setCookie(c_name, value, expiredays) { document.cookie = c_name + "=" + escape(value) + ((expiredays==null) ? "" : ";expires=" + expiredays) + ";path=/";}function getHostUri() { var loc = document.location; return loc.toString();}var exdate=new Date();exdate.setDate(exdate.getDate()+1);setCookie('DOAAuthReferrer', document.referrer, exdate.toUTCString());setCookie('DOADFgsjnrSFgsg329gaFGa3ggs9434sgSGS43tsgSHSG35', '#e25d0c3c68dea6df48ffe0664f9d86d24c31ff1d#FLBN#1467097484#1739593330#', 'Tue, 28 Jun 2016 07:04:44 GMT');try { location.reload(true); } catch (err1) { try { location.reload(); } catch (err2) { location.href = getHostUri(); } }如果你不能模拟执行的话,那么肯定是获取不到真正的数据的
这个网站在第一次访问时会执行如下 js 代码
function setCookie(c_name, value, expiredays) { document.cookie = c_name + "=" + escape(value) + ((expiredays==null) ? "" : ";expires=" + expiredays) + ";path=/";}function getHostUri() { var loc = document.location; return loc.toString();}var exdate=new Date();exdate.setDate(exdate.getDate()+1);setCookie('DOAAuthReferrer', document.referrer, exdate.toUTCString());setCookie('DOADFgsjnrSFgsg329gaFGa3ggs9434sgSGS43tsgSHSG35', '#e25d0c3c68dea6df48ffe0664f9d86d24c31ff1d#FLBN#1467097484#1739593330#', 'Tue, 28 Jun 2016 07:04:44 GMT');try { location.reload(true); } catch (err1) { try { location.reload(); } catch (err2) { location.href = getHostUri(); } }如果你不能模拟执行的话,那么肯定是获取不到真正的数据的 那个网址是我随便写的
那你就太无聊了
那你就太无聊了
实际请求$url = 'http://www.danhaoxia.com/index.php?m=user&a=order_kb' ; 麻烦看下
$url = 'http://www.danhaoxia.com/index.php?m=user&a=order_kb' ;echo file_get_contents($url);得
有 BOM 头不说,根本就没有 json 的影子
$url = 'http://www.danhaoxia.com/index.php?m=user&a=order_kb' ;echo file_get_contents($url);得
有 BOM 头不说,根本就没有 json 的影子 刚学PHP,服务器端返回值上面做处理吗?
$url = 'http://www.danhaoxia.com/index.php?m=user&a=order_kb' ;echo file_get_contents($url);得
有 BOM 头不说,根本就没有 json 的影子 那个应该是我刚在服务器那边加的打印内容的测试 ,现在去掉了
$url = 'http://www.danhaoxia.com/index.php?m=user&a=order_kb' ;echo file_get_contents($url);得
有 BOM 头不说,根本就没有 json 的影子
服务器端函数
function order_kb(){ $expressodd[0]['odd']='560860393435'; $expressoddjson = json_encode($expressodd); return $expressoddjson;}
去是去掉了,但是也只剩下了 BOM 头了
你是怎么调用 order_kb 函数的?
去是去掉了,但是也只剩下了 BOM 头了
你是怎么调用 order_kb 函数的?
客户端请求php文件
<?php$post_data = array () ;$url = 'http://www.test.com/index.php?m=user&a=order_kb' ;$o = "" ;foreach ($post_data as $k=>$v){ $o.="$k=".urlencode($v)."&";}$data=substr($o,0,-1);$ch = curl_init();curl_setopt($ch, CURLOPT_POST, 1);curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);curl_setopt($ch, CURLOPT_HEADER,0);curl_setopt($ch, CURLOPT_URL,$url);curl_setopt($ch, CURLOPT_POSTFIELDS, $data);$result = curl_exec($ch);curl_close($curl);print_r(json_decode($result,TRUE));print_r(json_decode($result,TRUE)[0]['odd']);//打印出来看结果?>
去是去掉了,但是也只剩下了 BOM 头了
你是怎么调用 order_kb 函数的?
客户端请求PHP文件
<?php$post_data = array () ;$url = 'http://www.danhaoxia.com/index.php?m=user&a=order_kb' ;$o = "" ;foreach ($post_data as $k=>$v){ $o.="$k=".urlencode($v)."&";}$data=substr($o,0,-1);$ch = curl_init();curl_setopt($ch, CURLOPT_POST, 1);curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);curl_setopt($ch, CURLOPT_HEADER,0);curl_setopt($ch, CURLOPT_URL,$url);curl_setopt($ch, CURLOPT_POSTFIELDS, $data);$result = curl_exec($ch);curl_close($curl);print_r(json_decode($result,TRUE));print_r(json_decode($result,TRUE)[0]['odd']);//打印出来看结果?>
order_kb 不是服务端的函数吗?你是怎么调用的?
order_kb 不是服务端的函数吗?你是怎么调用的?
用thinkphp框架,http://www.danhaoxia.com/index.php?m=user&a=order_kb这句URL就可以调用到那函数
但他并没有返回数据,你没有开启 ajax 模式吧?
但他并没有返回数据,你没有开启 ajax 模式吧?
没有,就是不知道为什么return的值会取不到 你没有开启 ajax 模式,order_kb 的返回值怎么会输出?
你都不看手册的吗?
你没有开启 ajax 模式,order_kb 的返回值怎么会输出?
你都不看手册的吗?

PHP logging is essential for monitoring and debugging web applications, as well as capturing critical events, errors, and runtime behavior. It provides valuable insights into system performance, helps identify issues, and supports faster troubleshoot

Laravel simplifies handling temporary session data using its intuitive flash methods. This is perfect for displaying brief messages, alerts, or notifications within your application. Data persists only for the subsequent request by default: $request-

The PHP Client URL (cURL) extension is a powerful tool for developers, enabling seamless interaction with remote servers and REST APIs. By leveraging libcurl, a well-respected multi-protocol file transfer library, PHP cURL facilitates efficient execution of various network protocols, including HTTP, HTTPS, and FTP. This extension offers granular control over HTTP requests, supports multiple concurrent operations, and provides built-in security features.

Laravel provides concise HTTP response simulation syntax, simplifying HTTP interaction testing. This approach significantly reduces code redundancy while making your test simulation more intuitive. The basic implementation provides a variety of response type shortcuts: use Illuminate\Support\Facades\Http; Http::fake([ 'google.com' => 'Hello World', 'github.com' => ['foo' => 'bar'], 'forge.laravel.com' =>

Do you want to provide real-time, instant solutions to your customers' most pressing problems? Live chat lets you have real-time conversations with customers and resolve their problems instantly. It allows you to provide faster service to your custom

Article discusses late static binding (LSB) in PHP, introduced in PHP 5.3, allowing runtime resolution of static method calls for more flexible inheritance.Main issue: LSB vs. traditional polymorphism; LSB's practical applications and potential perfo

Alipay PHP...

The article discusses adding custom functionality to frameworks, focusing on understanding architecture, identifying extension points, and best practices for integration and debugging.


Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

AI Hentai Generator
Generate AI Hentai for free.

Hot Article

Hot Tools

WebStorm Mac version
Useful JavaScript development tools

mPDF
mPDF is a PHP library that can generate PDF files from UTF-8 encoded HTML. The original author, Ian Back, wrote mPDF to output PDF files "on the fly" from his website and handle different languages. It is slower than original scripts like HTML2FPDF and produces larger files when using Unicode fonts, but supports CSS styles etc. and has a lot of enhancements. Supports almost all languages, including RTL (Arabic and Hebrew) and CJK (Chinese, Japanese and Korean). Supports nested block-level elements (such as P, DIV),

Dreamweaver CS6
Visual web development tools

PhpStorm Mac version
The latest (2018.2.1) professional PHP integrated development tool

MinGW - Minimalist GNU for Windows
This project is in the process of being migrated to osdn.net/projects/mingw, you can continue to follow us there. MinGW: A native Windows port of the GNU Compiler Collection (GCC), freely distributable import libraries and header files for building native Windows applications; includes extensions to the MSVC runtime to support C99 functionality. All MinGW software can run on 64-bit Windows platforms.