php ini_set更改php.ini配置功能

//ini_set具有更改php.ini设置的功能。此函数接收两个参数:需要调整的配置变量名,以及变量的新值。

//例如,在某脚本出现时增加最大执行时间(maximum execution time):

阅读全文

php 创建目录与php删除目录代码

$dir_name = "http://www.phprm.com";

if(mkdir($dir_name))    //在当前目录下创建目录tmp_data
{
    echo "目录".$dir_name."创建成功!";
   
    //在目录tmp_data中创建一个文件tmp.txt,并向其中写入一些内容
    if($fp = fopen($dir_name."/www.phprm.com.txt",'a'))
    {
        if(fwrite($fp,"put some contenets into file."))
        {
            echo "<hr>";
            echo "在目录".$dir_name."下创建文件tmp.txt";
        }
    }
}
else
{
    echo "创建目录失败!";
    exit;
}
echo "<hr>";

阅读全文

opendir、readdir和closedir(PHP操作目录和文件)

$dir = "d:www.phprm.com";

//打开目录$dir,并将目录句柄赋给变量$dh
if($dh = opendir($dir))
{
    //通过while循环,使用函数readdir获取文件名
    while(($file_name = readdir($dh)) !== false)
    {
        echo "file name: ".$file_name;
        echo "<br/>";
        echo "<br/>";
    }
   
    //处理完成后,关闭目录句柄$dh
    closedir($dh);
}

阅读全文

Email正则表达式与URL正则表达式

 $str_arr = array(
"mymail@phprm.com",
"my_mail@phprm.com",
"my-mail@phprm.com",
"my.mail@site.com.cn",
"mymail@site.com.ccoomm",
"mymail@site.cn",
"mymail@@@lsite.com",
"mymail@site",
"mymail@phprm.com",
"my2007@phprm.com",
"163mail_for-me777@phprm.com",
);

阅读全文

ip地址的正则表达式

//检查ip地址的正则表达式示例1。
 

$arr_ip = array(
"127.0.0.1",
"218.206.10.123",
"192.221.515.0",
"123.0.0.0.1",
"-12.255.0.10",
"10.9c.132.69",
"255.10.10.255"
);

阅读全文

php 文件上传简单实例应用

<html>
<head><title>php 文件上传简单实例应用</title></head>
<body>

<!-- 表单的enctype属性必须指定为multipart/form-data -->
<form enctype="multipart/form-data" action="3.php" method="post">
    上传此文件: <input name="myfile" type="file" />
    <input type="submit" value="提交上传" />
</form>

阅读全文