Welcome to the Treehouse Community
Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.
Looking to learn something new?
Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.
Start your free trialHeriberto Nieves
856 Pointswhat does the ! means if its before a variable?
i don't know what the ! represent before the variable, does it check somethings?
example: if ( !$variable1 || !$variable2 ) { echo 'text goes here'; }
im guessing it checks if the variable is empty? thanks
2 Answers
Steven Parker
231,269 PointsThat's the logical "not" operator. It means "the opposite of". So if the variable contains "false", then putting "!" in front will make the result "true".
Heriberto Nieves
856 Pointsthanks you!
Andres Vidoza
9,805 PointsAndres Vidoza
9,805 PointsThis actually checks that the string is empty?
Steven Parker
231,269 PointsSteven Parker
231,269 PointsThe "not" operator just inverts the value. An empty string by itself is considered to be "falsey", and one with content is considered "truthy".