How to check whether readfile was successful?

Please check the FAQ (https://www.xyplorer.com/faq.php) before posting a question...
Post Reply
autocart
Posts: 1391
Joined: 26 Sep 2013 15:22

How to check whether readfile was successful?

Post by autocart »

$text = readfile($inputfile);

?? Thx.

PeterH
Posts: 2830
Joined: 21 Nov 2005 20:39
Location: DE W11Pro 24H2, 1920*1200*100% 3840*2160*150%

Re: How to check whether readfile was successful?

Post by PeterH »

Not really exact - but test $text for "" :?:

autocart
Posts: 1391
Joined: 26 Sep 2013 15:22

Re: How to check whether readfile was successful?

Post by autocart »

if it was that simple I would not ask :wink:
i could think of contexts where $text might be "" before and if the file was empty then it might have the same result.
maybe i could check at the same time if property("size") == 0 but I am not sure if this is the case for all files who's readfile() results in "".

Of course, some errors (e.g. if the file is missing) result in a scripting error.
I don't know if all errors do that. (Because in this case this case would be closed.) Or if some silently return "" anyway.
If Don could enlighten us about that it would be nice, please, thx.

admin
Site Admin
Posts: 66677
Joined: 22 May 2004 16:48
Location: Win8.1, Win10, Win11, all @100%
Contact:

Re: How to check whether readfile was successful?

Post by admin »

It pops an error on failure.

autocart
Posts: 1391
Joined: 26 Sep 2013 15:22

Re: How to check whether readfile was successful?

Post by autocart »

admin wrote:It pops an error on failure.
ok, thx.

Post Reply