Basic rules to not-equal-to comparisons which are a bit more relaxed than the strictly not equal to comparison operator:
1 If a numeral is compared with a string, then a string copy will be made of the numeral and both strings are compared.
2 If a date is compared with a string, then a string copy will be made of the date and both strings are compared. Depending on the state of the date, the format is "YYYY-MM-DD", "HH:II:SS", or "YYYY-MM-DD HH:II:SS".
3 If a boolean value is compared with a string, then a string copy will be made of the boolean value and both strings are compared.
4 Contents in both sets must be the same, but the ordering does not matter. E.g. {1,2,3} <> {3,2,1} returns false, however strictly comparison {1,2,3} != {3,2,1} returns true. Values (but not subsets) inside the sets are compared with the strictly not equal to != operator.
echo("Basic comparisons:");
a[0] = 3 <> 3; // false
a[1] = 5.1 <> 5; // true
a[2] = 5 <> 2,3,5,7; // false
a[3] = 5 <> 2,2+1,5,7; // false
a[4] = 5 <> 1..3; // true
a[5] = 5 <> 4..7; // false
a[6] = 5 <> 1..3,5,7; // false
a[7] = {1,2,3} <> {3,2,1}; // false
for all variables( a[], x[] ) echo( x[] );
echo("String with other types:");
b[0] = 123 <> "123"; // false
b[1] = '123' <> 123; // false
b[2] = false <> 'false'; // false
b[3] = false <> 'False'; // true
b[4] = date("2020-08-01") <> "2020-08-01"; // false
b[5] = date("2020-08-01") <> "01.08.2020"; // true
// The last one is 'true' because string representation of date is YYYY-MM-DD
for all variables( b[], x[] ) echo( x[] );
echo("Compare with wildcards:");
c[0] = Hello World <> '*o*'; // Contains o, false
c[1] = Hello World <> "*o*"; // Not equal to string "*o*", true
c[2] = Hi <> 'Ha,Hi,Ho'; // Wildcard with commas, false
c[3] = Hi <> Ha,Hi,Ho; // Selection with commas, false
for all variables( c[], x[] ) echo( x[] );
Basic comparisons:
false
true
false
false
true
false
false
false
String with other types:
false
false
false
true
false
true
Compare with wildcards:
false
true
false
false
Note that value of type date may assume 4 states: date only, time only, date and time combined and blank date (no value). Even for the same operator,
the rules of calculating dates and numeric operands differ.
Note that in some cases, only the time or only the dates are compared.
d [] = date('2020-07-14');
dt[] = date('2020-07-14 12:30:00');
t [] = date('12:30:00');
o [] = date(''); // blank date
dz[] = date('2020-07-14 12:30:01');
a[0] = d[] <> dt[]; // false, dates same, time not compared
a[1] = t[] <> dt[]; // false, times same, date not compared
a[2] = d[] <> date("2020-07-15") - 1; // false
a[3] = dt[] <> dz[]; // true (time differs)
for all variables( a[], b[] ) echo( b[] );
false
false
false
true