Weird Operators in PHP
5 days ago
- #PHP
- #Programming
- #Operators
- PHP has a variety of operators, some readable like 'and', others less so like 'xor'.
- The 'b' operator adds a 'b' before strings but does nothing functional; it's a nod to PHP 6.
- The '[]=' operator is a shorthand for appending elements to an array, with mixed performance results.
- The '<-' operator was an experimental right-to-left coding feature, now defunct.
- The '-->' operator, or 'super object operator', works differently than '->' and requires an integer.
- The '<=' operator is a mirror version of '=>' for arrays, useful for mirror-writing.
- Constants can use special characters like '*' or '%' in names, provided their product matches the intended value.
- PHP 7 introduced the spaceship operator '<=>' and other fleet operators like tiny spaceship '-=-' and X-fighters '+-0-+'.
- The battleship operator '<=['-']=>' is an advanced array operator, simplifying array syntax.
- A 'death star' operator is rumored but not yet implemented in PHP.