Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to get error result of unlink

Tags:

php

If a call to unlink() returns false for the specified path, how do you find out what the reason for the failure was (i.e. EISDIR, ENOENT, ELOOP etc.)? PHP 5.x running on redhat linux.

like image 489
Jammie Podger Avatar asked Feb 25 '10 09:02

Jammie Podger


1 Answers

here's one way

unlink("/path/that/does/not/exist");
print_r(error_get_last());

See Error handling for more details

like image 86
ghostdog74 Avatar answered Oct 06 '22 23:10

ghostdog74