How to determine whether the php linux file path exists

藏色散人
Release: 2023-03-18 06:38:01
Original
2751 people have browsed it

php How to determine whether the linux file path exists: 1. Use the linux command "[ -f qipa250.txt ] && echo yes || echo no" to determine whether the file exists; 2. Call the linux command through php. The code is "$pdf_file_exists = '[ -f ' . $pdf_file_url . ' ] && echo true || echo false';".

How to determine whether the php linux file path exists

The operating environment of this tutorial: linux5.9.8 system, PHP8.1, Dell G3 computer.

php uses linux commands to determine whether the file exists

Linux command to determine whether the file exists

[ -f qipa250.txt ] && echo yes || echo no
Copy after login

-f File name is true if the file exists .

If [-f qipa250.txt] is true, echo yes will be executed. Echo no will no longer be executed due to the existence of the or statement ||.

It is important to note that the logic and logic here may be worthy of careful consideration.

php calls linux command method

//指定文件路径
$pdf_file_url='/data/web/QipaFile/qipa250.pdf';
//命令
$pdf_file_exists = '[ -f ' . $pdf_file_url . ' ] && echo true || echo false';
//执行
echo $pdf_file_exists_result = system($pdf_file_exists);
Copy after login

Recommended learning: "PHP Video Tutorial"

The above is the detailed content of How to determine whether the php linux file path exists. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template