Something that really would like to know but never found out are shortcuts in PHP.
I am currently coding a function with a foreach
loop with just a sing
To complement @Marko's answer, be aware that when using the dot operator for this matter, you should enclose each operation in parentheses, otherwise it will reverse the order.
For instance, this code below will print PHP >= 7.0 required yours is 5.6.15
.
(print "PHP >= 7.0 required yours is ") . (print phpversion()) . (print "\n");
While this will print 5.6.151PHP >= 7.0 required yours is 1
.
print("PHP >= 7.0 required yours is ") . print(phpversion()) . print("\n");
You can also use the and
operator for this to work. Like so:
if (PHP_VERSION_ID < 70000)
print("PHP >= 7.0 required yours is ") and
print(phpversion()) and
print("\n");