What to do if the php unlink function reports an error

青灯夜游
Release: 2023-03-12 17:06:02
Original
2623 people have browsed it

The reason why the unlink() function reported an error: The specified file to be deleted does not exist. Solution: Add an error suppressor "@" before the unlink() function, and the syntax is "@unlink($filename)". The "@" error suppressor can block some errors and warning messages caused by problems encountered during function execution.

What to do if the php unlink function reports an error

The operating environment of this tutorial: windows7 system, PHP7.1 version, DELL G3 computer

The unlink() function is used to delete the specified file , but if you want to delete a file that does not exist, unlink() will report an error.

<?php
$to_link = &#39;C:\Users\Administrator\Desktop\cut.jpg&#39;;
unlink($to_link);
?>
Copy after login

What to do if the php unlink function reports an error

If you want to block the error report of the unlink function, you can use the error suppressor "@" and add an error suppressor "@" before the unlink() function.

<?php
$to_link = &#39;C:\Users\Administrator\Desktop\cut.jpg&#39;;
@unlink($to_link);
?>
Copy after login

If you use @unlink(), no error will be reported.

Explanation: @Error suppressor

@ can shield some errors and warning messages caused by problems encountered during function execution, so that users cannot see the error messages of the program. In addition to a friendlier user interface, this is more important for security, because information such as the path to the error file is blocked.

Recommended learning: "PHP Video Tutorial"

The above is the detailed content of What to do if the php unlink function reports an error. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
@ php
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