Search code snippets, questions, articles...

Delete a file in PHP

    $filePath = 'path/to/file';
    unlink($filePath); //THIS FUNCTION DELETES THE FILE
Best JSON Validator, JSON Tree Viewer, JSON Beautifier at same place. Check how cool is the tool

To delete a file in PHP, you can use the inbuilt PHP function unlink($file). It requires a file path as its required parameter. This function will delete the file if found in the given location.

Search Index Data (The code snippet can also be found with below search text)

unlink() | PHP
Was this helpful?