Heim  >  Artikel  >  Backend-Entwicklung  >  PHP 远程调用问题!望高手帮忙教下怎么做!

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

WBOY
WBOYOriginal
2016-06-23 13:44:241014Durchsuche

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

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

Stellungnahme:
Der Inhalt dieses Artikels wird freiwillig von Internetnutzern beigesteuert und das Urheberrecht liegt beim ursprünglichen Autor. Diese Website übernimmt keine entsprechende rechtliche Verantwortung. Wenn Sie Inhalte finden, bei denen der Verdacht eines Plagiats oder einer Rechtsverletzung besteht, wenden Sie sich bitte an admin@php.cn