首页 > 作文

php is

更新时间:2023-04-06 13:38:25 阅读: 评论:0

is_file() 函数检查指定的文件名是否是正常的文件。

is_file — tells whether the filename is a regular file

用法

bool is_file ( string $filename ) $file 为必选参数

如果文件存在且五四青年节励志演讲稿为正常的文件则返回 true。

来看一个测试is_file经千里送鹅毛下一句典实例


复制代码 代码如下:

<?php

var_du1安等于多少毫安mp(is_file(‘a_file.txt’)) . “\n”;

var_dump(is_file(‘/usr/bin/’)) . “\n”;

?>

上例将输出:

bool(true)

bool(fal)

用法二


复制代码 代码如下:

<?php

function isfile($file){

return preg_match(‘/^[^.^:^?^-][^:^?]*.(?i)’ . getexts() . ‘$/’,$file);

//first character cannot be . : ? – subquent characters can’t be a : ?

//then a . character and must end with one of your extentions

//getexts() can be replaced with your extentions pattern

}
朗诵文章
function getexts(){

//list acceptable file extensions here

return ‘(app|avi|doc|docx|exe|ico|m学不进去id|midi|mov|mp3|

mpg|mpeg|pdf|psd|qt|ra|ram|rm|rtf|txt|wav|word|xls)’;

}

echo isfile(‘/urs/yoururname/sites/index.html’);

?>

实例三


复制代码 代码如下:

<?php

function deletefolder($path)

{

if ($handle=opendir($path))

{

while (fal!==($file=readdir($handle)))

{

if ($file<>”.” and $file<>”..”)

{

if (is_file($path.’/’.$file))

{

@unlink($path.’/’.$file);

}

if (is_dir($path.’/’.$file))

{

deletefolder($path.’/’.$file);

@rmdir($path.’/’.$file);

}

}

}

}

}

?>

此函数删除所有事情,定义的文件夹

本文发布于:2023-04-06 13:38:24,感谢您对本站的认可!

本文链接:https://www.wtabcd.cn/fanwen/zuowen/ab3f4b86c01d752162b9c7eb1587f6e8.html

版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。

本文word下载地址:php is.doc

本文 PDF 下载地址:php is.pdf

标签:代码   文件   函数   千里送鹅毛
相关文章
留言与评论(共有 0 条评论)
   
验证码:
Copyright ©2019-2022 Comsenz Inc.Powered by © 专利检索| 网站地图