2 Replies to “ Flow Condition – check string is empty ” Dan Sanders says: August 11, 2020 at 4:54 am Thanks Anita, very handy . It will return True if the given variable is empty and false if it exists or a non-zero or more than zero characters etc. When use ==, as you did, PHP treats NULL, false, 0, the empty string, and empty arrays as equal. empty() From PHP Manual – empty():. Your email address will not be published. PHP empty() function syntax: empty(“string”); PHP example of empty… The comparsion str === "" will only return true if the data type of the value is string and it is not empty, otherwise return false as demonstrated in the following example: It is very useful. First, it checks to see if the variable exists. If it does exist, then it checks to see if the variable is a “falsey” value. Particularly, in regards to user-submitted string … Required fields are marked * Comment. empty — Determine whether a variable is empty. The PHP function empty is often used to check if a particular variable is empty or not (duh). To check if a string is null or empty in Java, use the == operator. To add to @BJorn and @SeanPatrickFloyd The Guava way to do this is: Strings.nullToEmpty(str).isEmpty(); // or Strings.isNullOrEmpty(str); Commons Lang is more readable at times but I have been slowly relying more on Guava plus sometimes Commons Lang is confusing when it comes to isBlank() (as in what is whitespace or not).. Guava’s version of Commons Lang isBlank … In PHP the empty() function return true if the variable has empty or zero value and it return false if string has non-empty or non-zero value. Dinesh says: November 4, 2020 at 11:12 am Thanks Anita. share | improve this answer | follow | edited Dec 11 '19 at 23:39 It is enough to use either of the function. Here is a simple way to do a check that will work: