PHP 远程调用问题!望高手帮忙教下怎么做!

WBOY
Release: 2016-06-23 13:44:24
Original
1051 people have browsed it

以下是我自己弄的!
建立个 123.php文件 如下

$url = "http://www.123456.com/Ajax.ashx?Action=AddOrder&OrderIDShow=1&id=10086&Amt=10&Mb=2&Email=fdhfdf@qq.com";  $result = file_get_contents($url);   echo $result;
Copy after login

显示出的结果是 YES_5e286f3e

可是我想把 YES_去掉 单单显示出 5e286f3e 请问我需要怎么做! 本人小菜一个,望高手能帮忙解答!


回复讨论(解决方案)

你去到结果后如果你只是想去掉YES_那你完全可以采用正则或者是切割按照_来切割取后面的就好了。

$str = "YES_5e286f3e";$arr = explode('_',$str);echo $arr[1];
Copy after login

$url = "http://www.123456.com/Ajax.ashx?Action=AddOrder&OrderIDShow=1&id=10086&Amt=10&Mb=2&Email=fdhfdf@qq.com";
$result =explode('_',file_get_contents($url));
echo $result[1];

$result = ltrim('YES_5e286f3e','YES_');echo $result;
Copy after login

??就可以了。

$url = "http://www.123456.com/Ajax.ashx?Action=AddOrder&OrderIDShow=1&id=10086&Amt=10&Mb=2&Email=fdhfdf@qq.com";  $result = file_get_contents($url);   $result = str_replace('YES_', '', $result); // 把YES_替??空echo $result;
Copy after login

把'YES_'替换为空即可。
参考函数:str_replace();

虽然自己已经找到解决办法了 不过还是谢谢你们! 

source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template