一些PHP函数
2011-05-31 14:39
253 查看
<?php
/* 将URL中的某参数设为某值*/
function url_set_value($url,$key,$value)
{
$a=explode('?',$url);
$url_f=$a[0];
$query=$a[1];
parse_str($query,$arr);
$arr[$key]=$value;
return $url_f.'?'.http_build_query($arr);
}
//copy a direction’s all files to another direction
function xCopy($source, $destination, $child = false){
//用法:
// xCopy("feiy","feiy2",1):拷贝feiy下的文件到 feiy2,包括子目录
// xCopy("feiy","feiy2",0):拷贝feiy下的文件到 feiy2,不包括子目录
//参数说明:
// $source:源目录名
// $destination:目的目录名
// $child:复制时,是不是包含的子目录
if(!is_dir($source)){
echo("Error:the $source is not a direction!");
return 0;
}
if(!is_dir($destination)){
mkdir($destination,0777);
}
$handle=dir($source);
while($entry=$handle->read()) {
if(($entry!=".")&&($entry!="..")){
if(is_dir($source."/".$entry)){
if($child)
xCopy($source."/".$entry,$destination."/".$entry,$child);
}
else{
copy($source."/".$entry,$destination."/".$entry);
}
}
}
return 1;
}
///获取与当前PHP同一层的另外一个文件的全链接
$self_url = "http://" . $_SERVER['SERVER_NAME'] . $_SERVER['PHP_SELF'];
$last_slash_pos = strrpos($self_url, '/');
$cur_dir_url = substr($self_url, 0, $last_slash_pos);
$otherjumpurl = $cur_dir_url + "XXXX.php";
/* 将URL中的某参数设为某值*/
function url_set_value($url,$key,$value)
{
$a=explode('?',$url);
$url_f=$a[0];
$query=$a[1];
parse_str($query,$arr);
$arr[$key]=$value;
return $url_f.'?'.http_build_query($arr);
}
//copy a direction’s all files to another direction
function xCopy($source, $destination, $child = false){
//用法:
// xCopy("feiy","feiy2",1):拷贝feiy下的文件到 feiy2,包括子目录
// xCopy("feiy","feiy2",0):拷贝feiy下的文件到 feiy2,不包括子目录
//参数说明:
// $source:源目录名
// $destination:目的目录名
// $child:复制时,是不是包含的子目录
if(!is_dir($source)){
echo("Error:the $source is not a direction!");
return 0;
}
if(!is_dir($destination)){
mkdir($destination,0777);
}
$handle=dir($source);
while($entry=$handle->read()) {
if(($entry!=".")&&($entry!="..")){
if(is_dir($source."/".$entry)){
if($child)
xCopy($source."/".$entry,$destination."/".$entry,$child);
}
else{
copy($source."/".$entry,$destination."/".$entry);
}
}
}
return 1;
}
///获取与当前PHP同一层的另外一个文件的全链接
$self_url = "http://" . $_SERVER['SERVER_NAME'] . $_SERVER['PHP_SELF'];
$last_slash_pos = strrpos($self_url, '/');
$cur_dir_url = substr($self_url, 0, $last_slash_pos);
$otherjumpurl = $cur_dir_url + "XXXX.php";
//设置网页编码为utf8 @header('Content-Type:text/html;charset=utf-8')
相关文章推荐
- 一些常用封装的PHP函数
- 一些封装的php函数
- 一些冷门却很有用的php函数
- 一些神奇的php函数
- Joomla使用的一些基本的Php函数
- 整理一些PHP函数,这些函数用的不是非常多,但是又非常重要,如果适当的用起来,有可以提升性能
- 收集一些有用的php函数---from cmstop
- 一些php函数的整理
- 一些常用的php函数
- 很有用的一些PHP函数
- 一些被忽视的PHP函数(简单整理)
- 一些常用php函数整理
- 一些使用频率比较高的php函数
- 一些使用频率比较高的PHP函数
- 一些不常用的php函数
- 一些有效的php函数
- 一些常用的php函数
- 一些php函数
- PHP函数的一些冷知识
- 一些经典的php函数方法代码整理