the file电影

Keyboard Shortcuts?
Next menu item
Previous menu item
Previous man page
Next man page
Scroll to bottom
Scroll to top
Goto homepage
Goto search(current page)
Focus search box
Change language:
Brazilian Portuguese
Chinese (Simplified)
is_file & Tells whether the filename is a regular file
Description
bool is_file
( string $filename
Parameters
Path to the file.
Return Values
Returns TRUE if the filename exists and is a regular file, FALSE
otherwise.
Because PHP's integer type is signed and many platforms use 32bit integers,
some filesystem functions may return unexpected results for files which
are larger than 2GB.
Example #1 is_file() example
&?phpvar_dump(is_file('a_file.txt'))&.&"\n";var_dump(is_file('/usr/bin/'))&.&"\n";?&
The above example will output:
bool(true)
bool(false)
Errors/Exceptions
Upon failure, an E_WARNING is emitted.
Note: The results of this
function are cached. See
more details.
TipAs of PHP 5.0.0, this function
can also be used with some URL wrappers.
to determine which wrappers support
family of functionality.
- Tells whether the filename is a directory
- Tells whether the filename is a symbolic link
Note that is_file() returns false if the parent directory doesn't have + this make sense, but other functions such as readdir() don't seem to have this limitation. The end result is that you can loop through a directory's files but is_file() will always fail.
This Function deletes everything in a defined Folder:
Works with PHP 4 and 5.
&?php
& function deletefolder($path)
& {
& & if ($handle=opendir($path))
& & {
& & & while (false!==($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);
& & & & & }
& & & & }
& & & }
& & }
& }
?&
if you're running apache as a service on a win32 machine, an you try to determinate if a file on an other pc in your network exists - ex.: is_file('//servername/share/dir1/dir2/file.txt') - you may return false when you're running the service as LocalSystem. To avoid this, you have to start the Apache-Service as a 'registered' domain user.
I tend to use alot of includes, and I found that the is_file is based on the script executed, not ran.if you request /foo.php and foo.php looks like this:&?phpinclude('foobar/bar.php');?&and bar.php looks like this:&?phpecho (is_file('foo/bar.txt'));?&Then PHP (on win32, php 5.x) would look for /foo/bar.txt and not /foobar/foo/bar.txt.you would have to rewrite the is_file statement for that, or change working directory.Noting this since I sat with the problem for some time,cheers, Toxik.
regarding note from rehfeld dot us : In my experience the best( and easiest ) way to find the extension of a file is : &?php$extension = end(explode(".", $file_name));?&or &?php$parts = explode(".", $file_name);if (is_array($parts) && count($parts) & 1)& & $extension = end($parts);?&
Maybe this is a newbie mistake, but note that paths are relative to the filesystem and the location of the script.& This means that MS IIS virtual directories are not available by relative path - use an absolute.This threw me because virtual directories ARE available for URLs, at least on IIS.
this is a simple way to find specific files instead of using is_file().
this example is made for mac standards, but easily changed for pc.
&?php
function isfile($file){
& & return preg_match('/^[^.^:^?^\-][^:^?]*\.(?i)' . getexts() . '$/',$file);
& & }
function getexts(){
& & return '(app|avi|doc|docx|exe|ico|mid|midi|mov|mp3|
& & & & & & & && mpg|mpeg|pdf|psd|qt|ra|ram|rm|rtf|txt|wav|word|xls)';
}
echo isfile('/Users/YourUserName/Sites/index.html');
?&
In 32 bit environments, these functions including is_file(), stat() filesize() will not work due to PHPs default integer being signed. So anything above ~2.1 billion bytes you actually get a negative value.This is actually a bug but I dont think there is an easy workaround. Try to switch to 64 bit.
I see, is_file not work properly on specifical file in /dev (linux)look : root@boofh:/data# php -r "var_dump(is_file('/dev/core'));"bool(true)root@boofh:/data# php -r "var_dump(is_file('/proc/kcore'));"bool(true)root@boofh:/data# ls -alh /proc/kcore-r-------- 1 root root 128T Aug 13 18:39 /proc/kcoreOR FIND do not detect regular file.root@boofh:/data# find /dev/ -type froot@boofh:/data#// version of php :root@boofh:/data# php -vPHP 5.4.4-14+deb7u3 (cli) (built: Jul 17 :08)Copyright (c)
The PHP GroupZend Engine v2.4.0, Copyright (c)
Zend Technologies
It took me a day or so to figure out that is_file() actually looks for a valid $ existing path/file in string form. It is not performing a pattern-like test on the parameter given. Its testing to see if the given parameter leads to a specific& existing 'name.ext' or other (non-directory) file type object.
here is a workaround for the file size limit. uses bash file testing operator, so it may be changed to test directories etc.& (see
for possible test operators)&?phpfunction is_file_lfs($path){& & exec('[ -f "'.$path.'" ]', $tmp, $ret);& & return $ret == 0;}?&
Today I got the in the comments already described behaviour that between directory and file can't be distinguished by is_file() or is_dir().A dirty and incomplete hack is below, incomplete because it never includes links and I never tested what happens when a directory is not allowed to be read.$items = scandir($dir);foreach ($items as $item){& & if ($item!='.' && $item!='..'){& & & & $deep = @scandir($dir.'/'.$item);& & & & echo ($deep ? '[DIR] ':'[FILE] '.$item.nl2br(PHP_EOL);& & }}
is_file doesn't recognize files whose filenames contain strange characters like czech ? or russian characters in general.I've seen many scripts that take it for granted that a path is a directory when it fails is_file($path). When trying to determine whether a path links to a file or a dir, you should always use is_dir after getting false from is_file($path). For cases like described above, both will fail.
In PHP 4.1.0 under win32, this seems to print out a warning message if the file does not exist (using error_reporting = E_ALL & ~E_NOTICE).
I have noticed that using is_file on windows servers (mainly for development) to use a full path c:\ doesn't always work.I have had to useC:/foldertowww/site/file.extso I preform an str_replace('\\', '/', $path)Sometimes I have had the \ instead of / work. (this is using apache2 on XP)but for sure you cannot have mixed separators.
An easy way not to have to choose between hard-coding full paths and using relative paths is either via this line:&?phpdefine('DIR_ROOT', dirname(__FILE__));require(DIR_ROOT . '/relative/to/bootstrap.php');?&or if you have to use a relative path:&?phprequire(dirname(__FILE__) . '/relative/to/this_file.php');?&This way all your paths will be absolute, yet you can move the application anywhere in the filesystem.BTW, each successive call to dirname takes you one step up in the directory tree.&?phpecho __FILE__;echo dirname(__FILE__);echo dirname(dirname(__FILE__));?&
Please be aware wildcards do not work as one might expect.&?php$file = '*.*';if ( is_file($file) ) {& echo( $file . ' is a regular file' );} else {& echo( $file . ' is not a regular file' );}?&The above snippet suggests that *.* is a regular file. It does not sound regular to me. I would expect is_file() to return FALSE.
be careful, is_file() fails on files larger than your integer storage (2^32 for most).Warning: is_file(): Stat failed for bigfile (errno=75 - Value too large for defined data type)
### Symbolic links are resolved ###If you pass a symlink (unix symbolic link) as parameter, is_file will resolve the symlink and will give information about the refered file. For example:& touch file& ln -s file link& echo '&? if (is_file("link")) echo "y\n"; ?&' | php -qwill print "y".is_dir resolves symlinks too.
regarding rlh at d8acom dot com method,It is incorrect. Well, it works but you are not guaranteed the file extension using that method.for example :&& filename.inc.phpyour method will tell you the ext is "inc", but it is in fact "php"heres a way that will work properly.&?php$dh = opendir($dir);while (false !== ($document = readdir($dh))) {& & $pos = strrpos($document, '.');& & if (false !== $pos && strlen($document) & $pos + 1) {& & & & $ext = substr($document, $pos + 1);& & }}?&
I do a lot of file parsing and have found the following technique extremely useful:while (false !== ($document = readdir($my_dir))) {& & $ext=explode('.',$document);& & if($document != '.' && $document != '..' && $ext[1])& & {& & & & & & & & & & && 'Do something to file...'& & & & & & & }}It gets around the fact that, when working on website pages, the html files are read as directories when downloaded. It also allows you to extend the usefulness of the above method by adding the ability to determine file types e.g.if($document != '.' && $document != '..' && $ext[1]=='htm')orif($document != '.' && $document != '..' && $ext[1]=='doc')The V File Viewer has an optional dual pane interface which makes it easy to copy/move files from one directory to another.
Folder Tabs allow you to view favorite directories with a single mouse click (or key press). A Thumbnails Mode makes
browsing image directories a breeze.
For those who prefer to work in a Command Prompt, V is fast and convenient - just
type V Filename and the file is right in front of you. There is no need to switch to Windows Explorer
and certainly no need to bring up a File Open Dialog Box!
EBCDIC support (including common RECFM formats) makes it ideal for those who work in a mainframe environment.MySQL:&Starting&MySQL…..&ERROR!&The&server&quit&without&updating&PID&file解决办法
[root@localhost mysql]# /etc/rc.d/init.d/mysql status
MySQL is not running, but lock file
(/var/lock/subsys/mysql[FAILED][root@localhost mysql]#
/etc/rc.d/init.d/mysql start
Starting MySQL...The server quit without
updating PID file
(/usr/local/mysql/data/localhost.localdomain.pid).&&&&&&&&&&&&&&&&&&&&&&&&&&&&&
没有初始化权限表
3 解决办法
#cd /usr/local/mysql(进入mysql安装目录)
#chown -R mysql.mysql .
#su - mysql
$cd server
$scripts/mysql_install_db
4 本人解决过程
[root@localhost ~]# cd
/usr/local/mysql
[root@localhost mysql]# chown -R
mysql.mysql .[root@localhost mysql]# su - mysql[mysql@localhost ~]$ cd /usr/local/mysql[mysql@localhost mysql]$
scripts/mysql_install_dbInstalling MySQL
system tables...
Filling help tables...
To start mysqld at boot time you have to copy
support-files/mysql.server to the right place for your system
PLEASE REMEMBER TO SET A PASSWORD FOR THE MySQL root USER
To do so, start the server, then issue the following commands:
./bin/mysqladmin -u root password 'new-password'
./bin/mysqladmin -u root -h localhost.localdomain password
'new-password'
Alternatively you can run:
./bin/mysql_secure_installation
which will also give you the option of removing the test
databases and anonymous user created by default.&
strongly recommended for production servers.
See the manual for more instructions.
You can start the MySQL daemon with:
cd . ; ./bin/mysqld_safe &
You can test the MySQL daemon with mysql-test-run.pl
cd ./mysql- perl mysql-test-run.pl
Please report any problems with the ./bin/mysqlbug script!
[mysql@localhost mysql]$ /usr/local/mysql/bin/mysqld_safe --user=mysql
&[1] 11767
[mysql@localhost mysql]$ :01:17 mysqld_safe Logging to
'/usr/local/mysql/data/localhost.localdomain.err'.
:01:17 mysqld_safe Starting mysqld daemon with databases
from /usr/local/mysql/data
[mysql@localhost mysql]$ /etc/rc.d/init.d/mysql statusMySQL running
(11830)&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&
[mysql@localhost mysql]$ /etc/rc.d/init.d/mysql startStarting
MySQL&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&
附一文:MySQL:
Starting MySQL….. ERROR! The server quit without updating PID
This step-by-step guide is mainly for FreeBSD, however the idea is
the same for Linux. Every once a while, when I update my FreeBSD
box, the system likes to shutdown my MySQL server. Therefore, I
need to start it again after the update is done. Unfortunately, the
upgrade process is not smooth every time. Sometimes it will throw
me some error.
/usr/local/etc/rc.d/mysql.server start
Oh well, I got the following error messages:
Starting MySQL..... ERROR! The server quit without updating PID file.
Sometimes, the message will tell you the exact location of which
Starting MySQL..... ERROR! The server quit without updating PID file (/var/db/mysql/.pid).
There are several solutions to troubleshoot these problems. I
will go over each one by one.
Solution 1: Reboot The Computer
Although it sounds simple, but it really works. During the
system upgrade, the OS may disable some of your daemons. Instead of
troubleshooting each one by one, the easiest way is to start
everything over. For example, I experienced this problem today
after upgrading the Apache and Ruby (Yes, MySQL is
not part of the update), and I got this error message afterward.
After rebooting the computer, the error message is gone.
Solution 2: Remove Your MySQL Config File
If you have modified your MySQL configuration file, MySQL may
not like it few versions after (MySQL is not backward compatibility
friendly). It can be the problem of using an unsupported variable,
or something similar. The easiest way is to remove your
configuration file, and try to start the MySQL server again:
Backup your MySQL configuration first.
mv /f /f.backup
And restart the MySQL server again:
/usr/local/share/mysql/mysql.server start
Hopefully you will see the following message:
Starting MySQL. SUCCESS!
Solution 3: Upgrade Your Database File
Sometimes, the newer MySQL doesn’t like the database created in
earlier version. I discovered this when I upgrade to MySQL
Starting MySQL..... ERROR! The server quit without updating PID file (/var/db/mysql/.pid).
Since MySQL tells me which PID file causes the problem, I open
the file and take a look what’s going on:
sudo tail /var/db/mysql/.err
And I saw something interesting: tables: Table
‘mysql.proxies_priv’ doesn’t exist:
InnoDB: Initializing buffer pool, size = 128.0M
InnoDB: Completed initialization of buffer pool
InnoDB: highest supported file format is Barracuda.
InnoDB: 1.1.3 log sequence number 1589404
:49:17 [ERROR] Fatal error: Can't open and lock privilege tables: Table 'mysql.proxies_priv' doesn't exist
:49:17 mysqld_safe mysqld from pid file /var/db/mysql/.pid ended
The reason is very simple. MySQL could not open a table created
in the earlier version (& 5.7.7) because it is not
compatible with the current version. So, we can try to start the
MySQL in safe mode through rc.d. First, you can edit the
/etc/rc.conf and put the following into the
mysql_enable="YES"
mysql_args="--skip-grant-tables --skip-networking"
Restart MySQL through rc.d:
/usr/local/etc/rc.d/mysql-server start
If you did it right, you should see something like the
following:
Starting MySQL.. SUCCESS!
Now, MySQL is already running the safe-mode. We want to perform
a MySQL upgrade on all tables:
sudo mysql_upgrade
You should see something like this:
Looking for 'mysql' as: mysql
Looking for 'mysqlcheck' as: mysqlcheck
Running 'mysqlcheck' with connection arguments: '--port=3306' '--socket=/tmp/mysql.sock'
Running 'mysqlcheck' with connection arguments: '--port=3306' '--socket=/tmp/mysql.sock'
mysql.columns_priv
mysql.event
mysql.func
mysql.general_log
mysql.help_category
mysql.help_keyword
mysql.help_relation
mysql.help_topic
mysql.host
mysql.ndb_binlog_index
mysql.plugin
mysql.proc
mysql.procs_priv
mysql.servers
mysql.slow_log
mysql.tables_priv
mysql.time_zone
mysql.time_zone_leap_second
mysql.time_zone_name
mysql.time_zone_transition
mysql.time_zone_transition_type
mysql.user
Running 'mysql_fix_privilege_tables'...
Now, we want to switch the MySQL back to normal mode by
commenting the extra options in /etc/rc.conf:
mysql_enable="YES"
#mysql_args="--skip-grant-tables --skip-networking"
And restart MySQL through /etc/rc.d:
/usr/local/etc/rc.d/mysql-server restart
Now the MySQL is up and running again!
Happy MySQLing.
已投稿到:
以上网友发言只代表其个人观点,不代表新浪网的观点或立场。开机提示Checking file system on C: The type of the file s
故障现象:system checking 开机checking file 每次开机电脑都会这样 Checking file system on d: The type of the file systm is NTFS. Volume label is ...(乱码,我打不出来) 然后下面还有一堆东西刷出来 我百度
故障现象:&system checking&& 开机checking file&& 本文来自电脑故障查询网——电脑房网
&&&&&&&&& 每次开机电脑都会这样
&&&&&&&&&&&& Checking file system on d:
&&&&&&&&&&&&& The type of the file systm is NTFS.
&&&&&&&&&&&&& Volume label is ...(乱码,我打不出来)
&&&&&&&&&&&& 然后下面还有一堆东西刷出来&&&&&&&&&&
&&&&&&&&& 我百度上搜的说是不正常关机的后果说,可是我每次都是正常关机的啊,还有打开&我的电脑&,右键点击盘符,依次选择&属性&-&工具&-&查错&-&开始检查&,说是磁盘检查不能执行,因为磁盘检查使用程序需要独占访问磁盘上的一些windows文件,这些文件只有在重新启动windows后才能被访问,然后说你想计划磁盘访问在下一次启动计算机时执行吗? 本文来自电脑故障查询网——电脑房网
我不知道这个是什么东西就点了N。
C\D\E\F盘都是这样说的说,我上次这样弄的时候还能检查的,但是第二次就成这样子了。
这个怎么弄啊, 拜托了
& 本文来自电脑故障查询网——电脑房网
解决方案: 本文来自电脑故障查询网——电脑房网
1)这是系统在扫描你的,可能是你自己操作的问题,如果你非法关机,直接断电或者直接按电源关电,电脑开机的时候会对你的做检查,包括你的。
还有就是你的电脑真的硬盘有问题了,建议你使用电脑自己带的磁盘扫描工具进行扫描修复,如果比较严重用下面进行修复(如果这次扫描后下次不在扫描就是正常扫描,如果开机总是扫描硬盘请看下面,由其按下面方法修复一下磁盘试试)。
2)如果也没有非法关机,硬盘也没有问题,开机还是扫描,可以用下面的方法去掉系统扫描硬盘:
单击&开始/运行&,输入&regedit&回车打开注册表编辑器,依次选择&HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Session Manager&子键,然后在右侧窗口中找到&BootExecute&键值项并将其数值数据清空,重启即可(清空前选文件导出进行备份,这样如果需要在恢复备份)。 本文来自电脑故障查询网——电脑房网
系统自带的磁盘修复方法(如果磁盘真有问题,用这个方法修复一下):
具体步骤如下(以Windows XP为例),在我的电脑中选中盘符后单击鼠标右键,在弹出的驱动器属性窗口中依次选择 &工具&开始检查&并选择&自动修复文件系统错误&和&扫描并恢复坏扇区&,然后点击开始,扫描时间会因磁盘容量及扫描选项的不同而有所差异。
硬盘坏道将导致电脑系统文件损坏或丢失,电脑无法启动或死机。硬盘坏道可以采用NDD磁盘工具或Scandisk来修复。
还解决不了问题,还原一下系统或重装系统 本文来自电脑故障查询网——电脑房网
为什么每次开机出现checking file system on E {dede:field name='arcurl' /}
相信很多人都碰到过电脑开机后出现
&Checking file system on E:
The type of the file system is NTFS&&然后是一些数字的变化,最后一行是类似的&?? allocation units available on disk&,然后就进入系统桌面了&的情况吧。 {dede:field name='arcurl' /}
这一般都是非正常关机,如断电、按热启动键启动、或强制按电源键关机在开机造成的。 {dede:field name='arcurl' /}
由于关机的时候E盘里面的程序还在运行,每次开机硬盘都会自动自检,消除错误信息等,而如果非正常关机这些程序没有正常退出,那么下次在开机电脑就要从新执行自检,以便消除消除错误信息,正常的电脑有一次就好了,下次启动就不会出现这种情况了。 本文来自电脑故障查询网——电脑房网
如果每次开机都出现这样的情况有2个可能:一个是硬盘出现坏道了,这可能是硬盘本来就已经不佳了,突然碰到非法关机,硬盘读写磁头由于受到应急电流的冲击,结果和硬盘发生碰撞,就在硬盘留下了坏道,但是电脑还能使用,出现这种情况一般只能更换硬盘了。一个是电脑没有问题,但是留下了记忆的信息,结果每次都自检,消除的办法就是:开始-运行中输入chkdsk E: /x /f 回车,然后就出现个自动运行的dos窗口,等他运行完毕就没有问题了。 本文来自电脑故障查询网——电脑房网
chkdsk E: /x /f的意思是Windows发现在E盘里文件系统有问题
运行CHKDSK &使用选项/x /f& 来更正修复这些问题 本文来自电脑故障查询网——电脑房网
chkdsk的全称是checkdisk,就是磁盘检查的意思,它是当你的系统发生错误或者非法关机的时候由系统来调用检查磁盘的。基于所用的文件系统,创建和显示磁盘的状态报告。Chkdsk 还会列出并纠正磁盘上的错误。
(本文来自电脑故障查询网——电脑房网 ,转载请注明出处,谢谢)
------分隔线----------------------------
故障现象: xp系统,开机到登陆画面黑屏,重启后故障依旧,进...
想修改自动更新,却是灰色,查了资料后的解决办法如下: 自动...
据我们分析会出现NTLDR is Missing,Press CTRL+ALT+DEL to restart原因有以...
输入法切换不了,大致有以下2种情况,一种是可以在右下脚任栏...
电脑故障确实是千变万变,有的时候可能一个很不起眼的操作就...
故障现象: 有时,当我们尝试帮助功能时,系统提示不能打开帮...

我要回帖

更多关于 the 的文章

 

随机推荐