Page 1 of 1

The use of exclamation mark "!" in php

Posted: Tue Oct 29, 2002 11:42 pm
by jamal
Hi,
I am getting confused at times the way that the exclamation mark is used in php. Please can anyone tell me how the exclamation mark is used in php?? I mean something like if (!(.....){}
Thanks in advance.
Jamal

Posted: Tue Oct 29, 2002 11:59 pm
by mydimension
the exclamation mark is the negation operator. in negates a boolean value and in essence switches its value. so TRUE == !(FLASE)

Posted: Wed Oct 30, 2002 2:32 am
by twigletmac
To carry on from what mydimension said it is often used for things like -

Code: Select all

if (!is_dir($name)) {
which basically says check to see if this function is returning FALSE, or more specifically in this case that $name is not a directory.

Mac

Posted: Wed Oct 30, 2002 8:49 am
by mydimension
well said mac, just at 1 in the morning, explaining something becomes tiresome :lol: