Home  >  Article  >  Backend Development  >  PHP 远程调用问题!望高手帮忙教下怎么做!

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

WBOY
WBOYOriginal
2016-06-23 13:44:241054browse

以下是我自己弄的!
建立个 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;

显示出的结果是   YES_5e286f3e

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


回复讨论(解决方案)

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

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

$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;

??就可以了。

$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;

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

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

Statement:
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