socket 应该没有明确上限,反而PHP单个线程使用内存数量要考虑
解决方案 »
- 这是一段加密代码吗,具体是什么意思,有人知道吗
- 大神帮忙看下 怎么没执行我的错误处理代码啊
- discuz 用户注册时向主站user表和cdb_members表同步插入数据问题
- MYSQL中是否有类似ms sql的newid()函数,随机取记录
- 这个cookie 怎么样读写?
- 请教一个正则表达式
- 8990357高级技术群,刚刚踢掉80多个人,如果您想认真的讨论技术或发言活跃,够真诚的话请加入!
- 谁有简单的Weblog源程序?只要有数据库和日期更新的哪种,急用!我参考一下!!!!!!!!!
- 在PHP界面中进行邮箱登录的问题!
- 怎么才能知道当前项目是否安装的memcache
- 请大家帮忙看看啊!!!
- goole 搜索提示 用什么事件触发的
post1.php:class post2Url
{
function __construct( $url, $host, $port="" )
{
$this->url = $url;
$this->host = $host;
$this->port = ($port == "")? 80 : $port;
}
//$data是一数组
//数组$key是提交时的变量名
//数组$val是提交时的变量值
//例如array("a"=>"b") POST时为a=b
function post( $data )
{
$postdata = "";
while ( list( $key, $val ) = each( $data ) ) {
$postdata .= $key . "=" . $val . "&";
}
$postdata = substr( $postdata, 0, -1);
return $this->postval( $postdata );
}
function postval( $postdata )
{
$error;
$errorno;
$datalen = strlen( $postdata );
$fp = fsockopen( $this->host, $this->port,$errorno,$error,30);
if( $fp ){
$act = "POST ".$this->url." HTTP/1.1\r\n";
$act .= "Accept: text/html, image/gif, image/x-xbitmap, image/jpeg, image/pjpeg, application/vnd.ms-powerpoint, application/vnd.ms-excel, application/msword, */*\r\n";
// $act .= "Referer: http://localhost/post2.php\r\n";
// $act .= "Accept-Language: zh-cn\n";
$act .= "Content-Type: application/x-www-form-urlencoded\r\n";
// $act .= "Accept-Encoding: gzip, deflate\n";
$act .= "User-Agent: Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1)\r\n";
$act .= "Host: ".$host."\r\n";
$act .= "Connection: Close\r\n";
$act .= "Content-Length: ".$datalen."\r\n";
$act .= "Connection: Keep-Alive\r\n";
// $act .= "Cache-Control: no-cache\n";
// $act .= "Cookie: new_loginname=%c6%da%b4%fd2004; new_loginid=5372515; new_loginpwd=9F4F996CB25703DF; usersms_pop_type=1\n";
$act .= "\r\n";
$act .= $postdata;
// echo $act;
fputs( $fp, $act);
$i=1;
while( !feof($fp))
{
$msg = fgets($fp,4096);
if($i==10)//把response头去掉,只显示内容
{
header('Content-Type: text/xml');
echo $msg;
}
$i++;
}
fclose( $fp );
//echo $msg;
}
else{
echo $errorno;
echo "<br />".$error;
return false;
}
}
}$url="/post2.php";
$host="127.0.0.1";
$post2url=new post2url($url,$host,'80');
$data=array();
$str="<?xml version=\"1.0\" encoding=\"UTF-8\"?>";
$str.="<response>";
$str.="<code>200 </code>";
$str.="<desc>Ok </desc>";
$str.="</response>";
$data['name']=$str;
$post2url->post($data);post2.phpheader('Content-Type: text/xml');
echo "<?xml version=\"1.0\" encoding=\"UTF-8\"?>";
echo "<books>";
//这里是数据内容,可以有很多
echo "</books>";
$msg = fgets($fp,4096);
if($i==10)//把response头去掉,只显示内容
{
header('Content-Type: text/xml');
echo $msg;//这句只会运行一次,最多输出4096字节=.=
}
不知道我的理解对不对?能不能找出这些节点,可以让我重新组成完整的xml文件输出呢?
echo file_get_contents("http://127.0.0.1/post2.php");
顺便问一下,怎么在html网页里完整的显示xml内容,不用header(。type/xml)的话。