Attila Herbert
Attila Herbert

Reputation: 309

Consequences of using statements in conditions of if statement PHP

This might be an obvious question, but I haven't found the answer anywhere.

So if I check if a function is working or not, I put it in an if() condition, like this:

if(!fopen($filename, "w")) print "file not found";

But does it open the file? And does it erase it? (the mode "w" would cause that.)

Thanks!

Upvotes: 4

Views: 68

Answers (1)

Marcel Korpel
Marcel Korpel

Reputation: 21763

Yes, a function in an if statement will be executed as is.

Upvotes: 1

Related Questions