二种escape unescape在php写法

 更新时间:2016年11月25日 15:25  点击:1846

*/

function phpescape($str){
$sublen=strlen($str);
$restring="";
for ($i=0;$i<$sublen;$i++){
if(ord($str[$i])>=127){
$tmps教程tring=bin2hex(iconv("utf-8","ucs-2",substr($str,$i,2)));

if (!eregi("win",php_os)){
$tmpstring=substr($tmpstring,2,2).substr($tmpstring,0,2);
}
$restring.="%u".$tmpstring;
$i++;
} else {
$restring.="%".dechex(ord($str[$i]));
}
}
return $restring;
}


function unescape($str) {
$str = rawurldecode($str);
preg_match_all("/%u.{4}|&#x.{4};|&#d+;|.+/u",$str,$r);
$ar = $r[0];
foreach($ar as $k=>$v) {
if(substr($v,0,2) == "%u")
$ar[$k] = iconv("ucs-2","utf-8",pack("h4",substr($v,-4)));
elseif(substr($v,0,3) == "&#x")
$ar[$k] = iconv("ucs-2","utf-8",pack("h4",substr($v,3,-1)));
elseif(substr($v,0,2) == "&#") {
$ar[$k] = iconv("ucs-2","utf-8",pack("n",substr($v,2,-1)));
}
}
return join("",$ar);
}


function escape($str) {
preg_match_all("/[x80-xff].|[x01-x7f]+/",$str,$r);
$ar = $r[0];
foreach($ar as $k=>$v) {
if(ord($v[0]) < 128)
$ar[$k] = rawurlencode($v);
else
$ar[$k] = "%u".bin2hex(iconv("gb2312","ucs-2",$v));
}
return join("",$ar);
}


function unescape($str) {
$str = rawurldecode($str);
preg_match_all("/(?:%u.{4})|.+/",$str,$r);
$ar = $r[0];
foreach($ar as $k=>$v) {
if(substr($v,0,2) == "%u" && strlen($v) == 6)
$ar[$k] = iconv("ucs-2","gb2312",pack("h4",substr($v,-4)));
}
return join("",$ar);
}

最近网站经常被攻击,后来想到了一个利用php来防止网站受攻击的办法,下面是我的代码,代码不是最好的,根据自己的需求来做,下面来看看我的代码。

/*
*网站防ip攻击代码(anti-ip attack code website)2010-11-20,ver2.0
*mydalle.com anti-refresh mechanism
*design by www.111cn.net
*/

<?php
//查询禁止ip
$ip =$_server['remote_addr'];
$fileht=".htaccess2";
if(!file_exists($fileht))file_put_contents($fileht,"");
$filehtarr=@file($fileht);
if(in_array($ip."rn",$filehtarr))die("warning:"."<br>"."your ip address are forbided by mydalle.com anti-refresh mechanism, if you have any question pls emill to shop@mydalle.com!<br>(mydalle.com anti-refresh mechanism is to enable users to have a good shipping services, but there maybe some inevitable network problems in your ip address, so that you can mail to us to solve.)");

//加入禁止ip
$time=time();
$fileforbid="log/forbidchk.dat";
if(file_exists($fileforbid))
{ if($time-filemtime($fileforbid)>30)unlink($fileforbid);
else{
$fileforbidarr=@file($fileforbid);
if($ip==substr($fileforbidarr[0],0,strlen($ip)))
{
if($time-substr($fileforbidarr[1],0,strlen($time))>120)unlink($fileforbid);
elseif($fileforbidarr[2]>120){file_put_contents($fileht,$ip."rn",file_append);unlink($fileforbid);}
else{$fileforbidarr[2]++;file_put_contents($fileforbid,$fileforbidarr);}
}
}
}
//防刷新
$str="";
$file="log/ipdate.dat";
if(!file_exists("log")&&!is_dir("log"))mkdir("log",0777);
if(!file_exists($file))file_put_contents($file,"");
$allowtime = 60;//防刷新时间
$allownum=5;//防刷新次数
$uri=$_server['request_uri'];
$checkip=md5($ip);
$checkuri=md5($uri);
$yesno=true;
$ipdate=@file($file);
foreach($ipdate as $k=>$v)
{ $iptem=substr($v,0,32);
$uritem=substr($v,32,32);
$timetem=substr($v,64,10);
$numtem=substr($v,74);
if($time-$timetem<$allowtime){
if($iptem!=$checkip)$str.=$v;
else{
$yesno=false;
if($uritem!=$checkuri)$str.=$iptem.$checkuri.$time."1rn";
elseif($numtem<$allownum)$str.=$iptem.$uritem.$timetem.($numtem+1)."rn";
else
{
if(!file_exists($fileforbid)){$addforbidarr=array($ip."rn",time()."rn",1);file_put_contents($fileforbid,$addforbidarr);}
file_put_contents("log/forbided_ip.log",$ip."--".date("y-m-d h:i:s",time())."--".$uri."rn",file_append);
$timepass=$timetem+$allowtime-$time;
die("warning:"."<br>"."pls don't refresh too frequently, and wait for ".$timepass." seconds to continue, if not your ip address will be forbided automatic by mydalle.com anti-refresh mechanism!<br>(mydalle.com anti-refresh mechanism is to enable users to have a good shipping services, but there maybe some inevitable network problems in your ip address, so that you can mail to us to solve.)");
}
}
}
}
if($yesno) $str.=$checkip.$checkuri.$time."1rn";
file_put_contents($file,$str);
?>

 本款数据库连接类,他会自动加载sql防注入功能,过滤一些敏感的sql查询关键词,同时还可以增加判断字段 show table status的性质与show table类 获取数据库所有表名等。*/
@ini_set('mysql.trace_mode','off');
class mysql
{
 public $dblink;
 public $pconnect;
 private $search = array('/union(s*(/*.**/)?s*)+select/i', '/load_file(s*(/*.**/)?s*)+(/i', '/into(s*(/*.**/)?s*)+outfile/i');
 private $replace = array('union &nbsp; select', 'load_file &nbsp; (', 'into &nbsp; outfile');
 private $rs;

 function __construct($hostname,$username,$userpwd,$database,$pconnect=false,$charset='utf8')
 {
  define('allowed_htmltags', '<html><embed><title><meta><body><a><p><br><hr><h1><h2><h3><h4><h5><h6><font><u><i><b><strong><div><span><ol><ul><li><img><table><tr><td><map>');
  $this->pconnect=$pconnect;
  $this->dblink=$pconnect?mysql_pconnect($hostname,$username,$userpwd):mysql_connect($hostname,$username,$userpwd);
  (!$this->dblink||!is_resource($this->dblink)) && fatal_error("connect to the database unsuccessfully!");
  @mysql_unbuffered_query("set names {$charset}");
  if($this->version()>'5.0.1')
  {
   @mysql_unbuffered_query("set sql_mode = ''");
  }
  @mysql_select_db($database) or fatal_error("can not select table!");
  return $this->dblink;
 }

 function query($sql,$unbuffered=false)
 {
  //echo $sql.'<br>';
  $this->rs=$unbuffered?mysql_unbuffered_query($sql,$this->dblink):mysql_query($sql,$this->dblink);
  //(!$this->rs||!is_resource($this->rs)) && fatal_error("execute the query unsuccessfully! error:".mysql_error());
  if(!$this->rs)fatal_error('在执行sql语句 '.$sql.' 时发生以下错误:'.mysql_error());
  return $this->rs;
 }

 function fetch_one($sql)
 {
  $this->rs=$this->query($sql);
  return dircms_strips教程lashes($this->filter_pass(mysql_fetch_array($this->rs,mysql_assoc)));
 }

 function get_maxfield($filed='id',$table) // 获取$table表中$filed字段的最大值
 {
  $r=$this->fetch_one("select {$table}.{$filed} from `{$table}` order by `{$table}`.`{$filed}` desc limit 0,1");
  return $r[$filed];
 }

 function fetch_all($sql)
 {
  $this->rs=$this->query($sql);
  $result=array();
  while($rows=mysql_fetch_array($this->rs,mysql_assoc))
  {
   $result[]=$rows;
  }
  
  mysql_free_result($this->rs);
  return dircms_stripslashes($this->filter_pass($result));
 }

 function fetch_all_withkey($sql,$key='id')
 {
  $this->rs=$this->query($sql);
  $result=array();
  while($rows=mysql_fetch_array($this->rs,mysql_assoc))
  {
   $result[$rows[$key]]=$rows;
  }
  
  mysql_free_result($this->rs);
  return dircms_stripslashes($this->filter_pass($result));
 }

 function last_insert_id()
 {
  if(($insertid=mysql_insert_id($this->dblink))>0)return $insertid;
  else //如果 auto_increment 的列的类型是 bigint,则 mysql_insert_id() 返回的值将不正确.
  {
   $result=$this->fetch_one('select last_insert_id() as insertid');
   return $result['insertid'];
  }
 }

 function insert($tbname,$varray,$replace=false)
 {
  $varray=$this->escape($varray);
  $tb_fields=$this->get_fields($tbname); // mb.111cn.net 升级一下,增加判断字段是否存在
  
  foreach($varray as $key => $value)
  {
   if(in_array($key,$tb_fields))
   {
    $fileds[]='`'.$key.'`';
    $values[]=is_string($value)?'''.$value.''':$value;
   }
  }

  if($fileds)
  {
   $fileds=implode(',',$fileds);
   $fileds=str_replace(''','`',$fileds);
   $values=implode(',',$values);
   $sql=$replace?"replace into {$tbname}({$fileds}) values ({$values})":"insert into {$tbname}({$fileds}) values ({$values})";
   $this->query($sql,true);
   return $this->last_insert_id();
  }
  else return false;
 }

 function update($tbname, $array, $where = '')
 {
  $array=$this->escape($array);
  if($where)
  {
   $tb_fields=$this->get_fields($tbname); // www.111cn.net,增加判断字段是否存在
   
   $sql = '';
   foreach($array as $k=>$v)
   {
    if(in_array($k,$tb_fields))
    {
     $k=str_replace(''','',$k);
     $sql .= ", `$k`='$v'";
    }
   }
   $sql = substr($sql, 1);
   
   if($sql)$sql = "update `$tbname` set $sql where $where";
   else return true;
  }
  else
  {
   $sql = "replace into `$tbname`(`".implode('`,`', array_keys($array))."`) values('".implode("','", $array)."')";
  }
  return $this->query($sql,true);
 }
 
 function mysql_delete($tbname,$idarray,$filedname='id')
 {
  $idwhere=is_array($idarray)?implode(',',$idarray):intval($idarray);
  $where=is_array($idarray)?"{$tbname}.{$filedname} in ({$idwhere})":" {$tbname}.{$filedname}={$idwhere}";

  return $this->query("delete from {$tbname} where {$where}",true);
 }

 function get_fields($table)
 {
  $fields=array();
  $result=$this->fetch_all("show columns from `{$table}`");
  foreach($result as $val)
  {
   $fields[]=$val['field'];
  }
  return $fields;
 }

 function get_table_status($database)
 {
  $status=array();
  $r=$this->fetch_all("show table status from `".$database."`"); /////// show table status的性质与show table类似,不过,可以提供每个表的大量信息。
  foreach($r as $v)
  {
   $status[]=$v;
  }
  return $status;
 }

 function get_one_table_status($table)
 {
  return $this->fetch_one("show table status like '$table'");
 }

 function create_fields($tbname,$fieldname,$size=0,$type='varchar') // 2010-5-14 修正一下
 {  
  if($size)
  {
   $size=strtoupper($type)=='varchar'?$size:8;
   $this->query("alter table `{$tbname}` add `$fieldname` {$type}( {$size} )  not null",true);
  }
  else $this->query("alter table `{$tbname}` add `$fieldname` mediumtext  not null",true);
  return true;
 }

 function get_tables() //获取所有表表名
 {
  $tables=array();
  $r=$this->fetch_all("show tables");
  foreach($r as $v)
  {
   foreach($v as $v_)
   {
    $tables[]=$v_;
   }
  }
  return $tables;
 }

 function create_model_table($tbname) //创建一个内容模型表(start:初始只有字段contentid int(20),用于内容表,/////////////////////// update:2010-5-20     默认加入`content` mediumtext not null,字段)
 {
  if(in_array($tbname,$this->get_tables())) return false;  ///////////////////// 当表名已经存在时,返回 false
  if($this->query("create table `{$tbname}` (
`contentid` mediumint(8) not null ,
`content` mediumtext not null,
key ( `contentid` )
) engine = myisam default charset=utf8",true))return true;   ////////////////////  成功则返回 true
  return false; //////////////失败返回 false
 }

 function create_table($tbname) //创建一个会员模型空表(初始只有字段userid int(20),用于会员表,2010-4-26)
 {
  if(in_array($tbname,$this->get_tables())) return false;
  if($this->query("create table `{$tbname}` (
`userid` mediumint(8) not null ,
key ( `userid` )
) engine = myisam default charset=utf8",true))return true;
  return false;
 }

 function escape($str) // 过滤危险字符
 {
  if(!is_array($str)) return str_replace(array('n', 'r'), array(chr(10), chr(13)),mysql_real_escape_string(preg_replace($this->search,$this->replace, $str), $this->dblink));
  foreach($str as $key=>$val) $str[$key] = $this->escape($val);
  return $str;
 }

 function filter_pass($string, $allowedtags = '', $disabledattributes = array('onabort', 'onactivate', 'onafterprint', 'onafterupdate', 'onbeforeactivate', 'onbeforecopy', 'onbeforecut', 'onbeforedeactivate', 'onbeforeeditfocus', 'onbeforepaste', 'onbeforeprint', 'onbeforeunload', 'onbeforeupdate', 'onblur', 'onbounce', 'oncellchange', 'onchange', 'onclick', 'oncontextmenu', 'oncontrolselect', 'oncopy', 'oncut', 'ondataavaible', 'ondatasetchanged', 'ondatasetcomplete', 'ondblclick', 'ondeactivate', 'ondrag', 'ondragdrop', 'ondragend', 'ondragenter', 'ondragleave', 'ondragover', 'ondragstart', 'ondrop', 'onerror', 'onerrorupdate', 'onfilterupdate', 'onfinish', 'onfocus', 'onfocusin', 'onfocusout', 'onhelp', 'onkeydown', 'onkeypress', 'onkeyup', 'onlayoutcomplete', 'onload', 'onlosecapture', 'onmousedown', 'onmouseenter', 'onmouseleave', 'onmousemove', 'onmoveout', 'onmouseo教程ver', 'onmouseup', 'onmousewheel', 'onmove', 'onmoveend', 'onmovestart', 'onpaste', 'onpropertychange', 'onreadystatechange', 'onreset', 'onresize', 'onresizeend', 'onresizestart', 'onrowexit', 'onrowsdelete', 'onrowsinserted', 'onscroll', 'onselect', 'onselectionchange', 'onselectstart', 'onstart', 'onstop', 'onsubmit', 'onunload'))
 {
  if(is_array($string))
  {
   foreach($string as $key => $val) $string[$key] = $this->filter_pass($val, allowed_htmltags);
  }
  else
  {
   $string = preg_replace('/s('.implode('|', $disabledattributes).').*?([s>])/', '', preg_replace('/<(.*?)>/ie', "'<'.preg_replace(array('/网页特效:[^"']*/i', '/(".implode('|', $disabledattributes).")[ ]*=[ ]*["'][^"']*["']/i', '/s+/'), array('', '', ' '), stripslashes('')) . '>'", strip_tags($string, $allowedtags)));
  }
  return $string;
 }

 function drop_table($tbname)
 {
  return $this->query("drop table if exists `{$tbname}`",true);
 }

 function version()
 {
  return mysql_get_server_info($this->dblink);
 }
}

php通用防注入主要是过滤一些sql命令与php post get传过来的参考我们/要过滤一些非法字符,这样可以防止基本的注入了,那关第于apache 服务器安装设置方法也是必须的。管理员用户名和密码都采取md5加密,这样就能有效地防止了php的注入。

还有服务器和mysql教程也要加强一些安全防范。
对于linux服务器的安全设置:
加密口令,使用“/usr/sbin/authconfig”工具打开密码的shadow功能,对password进行加密。
禁止访问重要文件,进入linux命令界面,在提示符下输入:
#chmod 600 /etc/inetd.conf    //改变文件属性为600
#chattr +i  /etc/inetd.conf     //保证文件属主为root
#chattr –i  /etc/inetd.conf     // 对该文件的改变做限制  
禁止任何用户通过su命令改变为root用户
在su配置文件即/etc/pam.d/目录下的开头添加下面两行:
auth  sufficient  /lib/security/pam_rootok.so debug
auth  required  /lib/security/pam_whell.so group=wheel
删除所有的特殊帐户
#userdel  lp等等    删除用户
#groupdel lp等等    删除组
禁止不使用的suid/sgid程序
#find / -type f (-perm -04000  - o –perm -02000 ) -execls –lg {} ;

 代码如下 复制代码
$arrfiltrate=array("'",";","union","select","insert","update","delete","load_file","outfile");

 //出错后要跳转的url

 代码如下 复制代码

$strgourl="";  

function funstringexist($strfiltrate,$arrfiltrate)
{
  foreach ($arrfiltrate as $key=>$value)
  {
    if (eregi($value,$strfiltrate))
    {
      return true;
    }
  }
  return false;
}

//合并$_post 、 $_get和$_cookie

 代码如下 复制代码
if(function_exists(array_merge))   
{
  $arrpostgetcookiesession=array_merge($http_post_vars,$http_get_vars,$http_cookie_vars); 
  $string = implode("",$arrpostgetcookiesession);
}

//验证

 代码如下 复制代码
if(funstringexist($string,$arrfiltrate))
{
  echo "<script language="网页特效">alert("提示,非法字符");</script>";
}
else
{
  echo "<script language="javascript">window.location="".$strgourl."";</script>";
}

第二款防注入实例

 代码如下 复制代码

php通用防注入安全代码
说明:
判断传递的变量中是否含有非法字符
如$_post、$_get
功能:
防注入
**************************/
//要过滤的非法字符
$arrfiltrate=array("'",";","union");
//出错后要跳转的url,不填则默认前一页
$strgourl="";
//是否存在数组中的值
function funstringexist($strfiltrate,$arrfiltrate){
foreach ($arrfiltrate as $key=>$value){
if (eregi($value,$strfiltrate)){
return true;
}
}
return false;
}
//合并$_post 和 $_get
if(function_exists(array_merge)){
$arrpostandget=array_merge($http_post_vars,$http_get_vars);
}else{
foreach($http_post_vars as $key=>$value){
$arrpostandget[]=$value;
}
foreach($http_get_vars as $key=>$value){
$arrpostandget[]=$value;
}
}
//验证开始
foreach($arrpostandget as $key=>$value){
if (funstringexist($value,$arrfiltrate)){
echo "alert(/"neeao提示,非法字符/");";
if (empty($strgourl)){
echo "history.go(-1);";
}else{
echo "window.location=/"".$strgourl."/";";
}
exit;
}
}


看一下关于注入细节

转化成ascii后是char(97,108,112,104,97)
转化成16进制是0x616c706861
(我们将在光盘中提供16进制和ascii转换工具)
好了直接在浏览器里输入:

 代码如下 复制代码
http://localhost/site/admin/login.php?
username=char(97,108,112,104,97)%23


sql语句变成:

 代码如下 复制代码

select * from alphaaut

hor where username=char(97,108,112,104,97)# and password=


如图21


  正如我们期望的那样,他顺利执行了,我们得到我们想要的。
  当然咯,我们也可以这样构造

 代码如下 复制代码
http://www.111cn.net/site/admin/login.php?username=0x616c706861%23


sql语句变成:

 代码如下 复制代码
select * from alphaauthor where username
=0x616c706861%23# and password=


我们再一次是成功者了。很有成就感吧,

或许你会问我们是否可以把#也放在char()里
实际上char(97,108,112,104,97)相当于 alpha
注意是alpha上加引号,表示alpha字符串。
我们知道在mysql中如果执行

 代码如下 复制代码
mysql> select * from dl_users where username=alpha;
error 1054 (42s22): unknown column alpha in where clause


看返回错误了。因为他会认为alpha是一个变量。所以我们得在alpha上加引号。
如下

 代码如下 复制代码
mysql> select * from dl_users where username= alpha ;

 

本文章提供这款防sql注入代码是一款php sql 双过滤非法字符的函数,他可以根据用户自定的防sql注入哦,先是过滤一些sql命令,再是就是把post get 过滤一次,最好验证。

//防注入

 代码如下 复制代码
$arrfiltrate=array("update","delete","selert","drop","exec","cast","'","union");
//出错后要跳转的url,不填则默认前一页
$strgourl="";
//是否存在数组中的值
function funstringexist($strfiltrate,$arrfiltrate){
    foreach ($arrfiltrate as $key=>$value){
        if (eregi($value,$strfiltrate)){
            return true;
        }
    }
return false;
}
//合并$_post 和 $_get
if(function_exists(array_merge)){
    $arrpostandget=array_merge($http_post_vars,$http_get_vars);
}else{
    foreach($http_post_vars as $key=>$value){
        $arrpostandget[]=$value;
    }
    foreach($http_get_vars as $key=>$value){
    $arrpostandget[]=$value;
    }
}
//验证开始
foreach($arrpostandget as $key=>$value){
    if (funstringexist($value,$arrfiltrate)){
        echo " ";
        if (empty($strgourl)){
            echo " ";
        }else{
            echo " ";
        }
        echo "<script>alert('系统检测到非法字符!');history.back();</script>";
        exit();
    }
}
?>
[!--infotagslink--]

相关文章

  • 源码分析系列之json_encode()如何转化一个对象

    这篇文章主要介绍了源码分析系列之json_encode()如何转化一个对象,对json_encode()感兴趣的同学,可以参考下...2021-04-22
  • php中去除文字内容中所有html代码

    PHP去除html、css样式、js格式的方法很多,但发现,它们基本都有一个弊端:空格往往清除不了 经过不断的研究,最终找到了一个理想的去除html包括空格css样式、js 的PHP函数。...2013-08-02
  • index.php怎么打开?如何打开index.php?

    index.php怎么打开?初学者可能不知道如何打开index.php,不会的同学可以参考一下本篇教程 打开编辑:右键->打开方式->经文本方式打开打开运行:首先你要有个支持运行PH...2017-07-06
  • PHP中func_get_args(),func_get_arg(),func_num_args()的区别

    复制代码 代码如下:<?php function jb51(){ print_r(func_get_args()); echo "<br>"; echo func_get_arg(1); echo "<br>"; echo func_num_args(); } jb51("www","j...2013-10-04
  • PHP实现今天是星期几的几种写法

    复制代码 代码如下: // 第一种写法 $da = date("w"); if( $da == "1" ){ echo "今天是星期一"; }else if( $da == "2" ){ echo "今天是星期二"; }else if( $da == "3" ){ echo "今天是星期三"; }else if( $da == "4"...2013-10-04
  • PHP编程 SSO详细介绍及简单实例

    这篇文章主要介绍了PHP编程 SSO详细介绍及简单实例的相关资料,这里介绍了三种模式跨子域单点登陆、完全跨单点域登陆、站群共享身份认证,需要的朋友可以参考下...2017-01-25
  • PHP实现创建以太坊钱包转账等功能

    这篇文章主要介绍了PHP实现创建以太坊钱包转账等功能,对以太坊感兴趣的同学,可以参考下...2021-04-20
  • php微信公众账号开发之五个坑(二)

    这篇文章主要为大家详细介绍了php微信公众账号开发之五个坑,具有一定的参考价值,感兴趣的小伙伴们可以参考一下...2016-10-02
  • ThinkPHP使用心得分享-ThinkPHP + Ajax 实现2级联动下拉菜单

    首先是数据库的设计。分类表叫cate.我做的是分类数据的二级联动,数据需要的字段有:id,name(中文名),pid(父id). 父id的设置: 若数据没有上一级,则父id为0,若有上级,则父id为上一级的id。数据库有内容后,就可以开始写代码,进...2014-05-31
  • PHP如何通过date() 函数格式化显示时间

    这篇文章主要介绍了PHP如何通过date() 函数格式化显示时间,文中通过示例代码介绍的非常详细,对大家的学习或者工作具有一定的参考学习价值,需要的朋友可以参考下...2020-11-13
  • PHP+jQuery+Ajax实现多图片上传效果

    今天我给大家分享的是在不刷新页面的前提下,使用PHP+jQuery+Ajax实现多图片上传的效果。用户只需要点击选择要上传的图片,然后图片自动上传到服务器上并展示在页面上。...2015-03-15
  • golang与php实现计算两个经纬度之间距离的方法

    这篇文章主要介绍了golang与php实现计算两个经纬度之间距离的方法,结合实例形式对比分析了Go语言与php进行经纬度计算的相关数学运算技巧,需要的朋友可以参考下...2016-07-29
  • PHP正则表达式过滤html标签属性(DEMO)

    这篇文章主要介绍了PHP正则表达式过滤html标签属性的相关内容,实用性非常,感兴趣的朋友参考下吧...2016-05-06
  • 谈谈PHP中相对路径的问题与绝对路径的使用

    经常看到有人踩在了PHP路径的坑上面了,感觉有必要来说说PHP中相对路径的一些坑,以及PHP中绝对路径的使用,下面一起来看看。 ...2016-08-24
  • php构造方法中析构方法在继承中的表现

    这篇文章主要为大家详细介绍了php构造方法中析构方法在继承中的表现,感兴趣的小伙伴们可以参考一下...2016-04-15
  • thinkPHP中多维数组的遍历方法

    这篇文章主要介绍了thinkPHP中多维数组的遍历方法,以简单实例形式分析了thinkPHP中foreach语句的使用技巧,需要的朋友可以参考下...2016-01-12
  • PHP如何使用cURL实现Get和Post请求

    这篇文章主要介绍了PHP如何使用cURL实现Get和Post请求,文中通过示例代码介绍的非常详细,对大家的学习或者工作具有一定的参考学习价值,需要的朋友可以参考下...2020-07-11
  • php图片添加文字水印实现代码

    这篇文章主要为大家详细介绍了php图片添加文字水印实现代码,具有一定的参考价值,感兴趣的小伙伴们可以参考一下...2016-03-17
  • php有序列表或数组中删除指定的值的实现代码

    这篇文章主要介绍了php有序列表或数组中删除指定的值的实现代码,删除给定的值之后,得到一个新的有序列表,长度-1,下面是具体的实现方法...2021-08-22
  • PHP简单实现生成txt文件到指定目录的方法

    这篇文章主要介绍了PHP简单实现生成txt文件到指定目录的方法,简单对比分析了PHP中fwrite及file_put_contents等函数的使用方法,需要的朋友可以参考下...2016-04-28