Code前端首页关于Code前端联系我们

php读取远程xml,php远程控制

terry 2年前 (2023-09-30) 阅读数 43 #PHP
文章标签 PHP Date()

本文目录一览:

  • 1、PHP怎么读取远程的这个XML文档,并输出
  • 2、怎么用php获取远程xml到本地
  • 3、php读取远程xml文件简单方法

PHP怎么读取远程的这个XML文档,并输出

首先你要有读的权限,方法可以使用fopen,个人比较喜欢使用file_get_content

$content=file_get_content("********/*******.xml");

echo $content;

怎么用php获取远程xml到本地

?php

$xml_string = file_get_contents("php://input");

$xml_string = trim($xml_string);

$xml_object = simplexml_load_string($xml_string);

$xml_arr = get_object_vars($xml_object);

只要别人访问你这个文件传递xml。你就能获取其中的信息了。

php读取远程xml文件简单方法

?php 

set_time_limit(0); 

function _rand() { 

$length=26; 

$chars = "0123456789abcdefghijklmnopqrstuvwxyz"; 

$max = strlen($chars) - 1; 

mt_srand((double)microtime() * 1000000); 

$string = ''; 

for($i = 0; $i  $length; $i++) { 

$string .= $chars[mt_rand(0, $max)]; 

return $string; 

$HTTP_SESSION=_rand(); 

$HTTP_SESSION; 

$ch = curl_init(); 

curl_setopt ($ch,CURLOPT_URL,";theUserID=theCityCode=贵港"); 

curl_setopt($ch,CURLOPT_RETURNTRANSFER,true); 

curl_setopt($ch,CURLOPT_USERAGENT,"Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; SV1; .NET CLR 1.1.4322; .NET CLR 2.0.50727)"); 

$res = curl_exec($ch); 

curl_close ($ch); 

//print_r($res); 

$xml_array=simplexml_load_string($res);

//   

foreach($xml_array as $tq){  

echo $tq;

}  

?

版权声明

本文仅代表作者观点,不代表Code前端网立场。
本文系作者Code前端网发表,如需转载,请注明页面地址。

热门