function dfopen($url, $limit = 0, $post = '', $cookie = '', $bysocket = FALSE, $ip = '', $timeout = 15, $block = TRUE)
{
$return = '';
$uri = parse_url(/blog_article/$url/index.html);
$host = $uri['host'];
$path = $uri['path'] ? $uri['path'].($uri['query'] ? '?'.$uri['query'] : '') : '/';
$port = !empty($uri['port']) ? $uri['port'] : 80;
if($post) {
$out = "POST $path HTTP/1.0\r\n";
$out .= "Accept: */*\r\n";
$out .= "Accept-Language: zh-cn\r\n";
$out .= "Content-Type: application/x-www-form-urlencoded\r\n";
$out .= "User-Agent: $_SERVER[HTTP_USER_AGENT]\r\n";
$out .= "Host: $host\r\n";
$out .= 'Content-Length: '.strlen($post)."\r\n";
$out .= "Connection: Close\r\n";
$out .= "Cache-Control: no-cache\r\n";
$out .= "Cookie: $cookie\r\n\r\n";
$out .= $post;
} else {
$out = "GET $path HTTP/1.0\r\n";
$out .= "Accept: */*\r\n";
$out .= "Accept-Language: zh-cn\r\n";
$out .= "User-Agent: $_SERVER[HTTP_USER_AGENT]\r\n";
$out .= "Host: $host\r\n";
$out .= "Connection: Close\r\n";
$out .= "Cookie: $cookie\r\n\r\n";
}
$fp = @fsockopen(($ip ? $ip : $host), $port, $errno, $errstr, $timeout);
if(!$fp) {
return '';
} else {
stream_set_blocking($fp, $block);
stream_set_timeout($fp, $timeout);
@fwrite($fp, $out);
@fclose($fp);
}
}
例:
dfopen("http://sina.com",0);
本文链接:http://www.cnblogs.com/chenshuanj/p/3275863.html,转载请注明。
class_exists — 检查类是否已定义,如果类存在返回true
get_class — 返回对象的类名
get_class_methods — 返回由类的方法名组成的数组
get_declared_classes — 返回由已定义类的名字所组成的数组
is_callable — 检测参数是否为合法的可调用结构
method_exists — 检查类的方法是否存在
检查类的方法是否存在于指定的 object中。
get_class_vars — 返回由类的默认属性组成的数组(只显示public属性)
返回由类的默认公有属性组成的关联数组,此数组的元素以 varname => value 的形式存在。
get_parent_class — 返回对象或类的父类名
is_subclass_of — 如果此对象是该类的子类,则返回 TRUE
call_user_func — Call the callback given by the first parameter
call_user_func_array — Call a callback with an array of parameters
flectionClass 类报告了一个类的有关信息。
Reflection::export — Exports
本文链接:http://www.cnblogs.com/klj123wan/p/3276547.html,转载请注明。
php单链表实现
//单链表
class Hero{
public $no;
public $name;
public $nickname;
public $next=null;
function __construct($no='',$name=''){
$this->no=$no;
$this->name=$name;
}
}
function addHero($head,$Hero){
$cur=$head;
$flag=true;
while ($cur->next!=null) {
if($cur->next->no>$Hero->no){
$tmp=$cur->next;
$cur->next=$Hero;
$Hero->next=$tmp;
$flag=false;break;
}else if($cur->next->no==$Hero->no){echo "该位置已有人,不允许占位";$flag=false;break;}
else{ $cur=$cur->next;}
}
if($flag){$cur->next=$Hero;}
}
//增加
function showHero($head){
$cur=$head;
while($cur->next!=null){
echo $cur->next->no.":".$cur->next->name."<br/>";
$cur=$cur->next;
}
}
//删除特定编号的
function delHero($head,$no){
$cur=$head;
while($cur->next!=null){
if($cur->next->no==$no)
{if($cur->next->next)$cur->next=$cur->next->next;
else $cur->next=null;
break;
}
$cur=$cur->next;
}
}
//查找特定编号的信息
function findHero($head,$no){
$cur=$head;
while($cur->next!=null){
if($cur->next->no==$no){break;}
$cur=$cur->next;
}
echo$cur->next->name;
}
//改特定编号的信息
function updateHero($head,$no,$name){
$cur=$head;
while($cur->next!=null){
if($cur->next->no==$no){break;}
$cur=$cur->next;
}
$cur->next->name=$name;
}
$head=new Hero();
$Hero=new Her