Expressions And Operators: Introduction
When combined, operators evaluate according to their associativity. For more information, see Operator Precedence.
Assignment Operators
- Assignment (
=
,+=
, and more) - Coalescing Assignment (
??=
)
Comparison Operators
- Comparison (
>
,>=
,<
,<=
) - Equality Comparison (
==
,!=
,===
,!==
) - Logical Comparison (
&&
,||
,!
) - Spaceship Comparator (
<=>
)
Arithmetic Operators
- Arithmetic (
+
,-
,*
,/
, and more) - Increment (
++
) - Decrement (
--
)
Bitwise and Bit Shift Operators
- Bitwise (
&
,|
,^
,<<
,>>
,~
)
Class and Member Operators
- Access Instance Properties and Methods (
->
,?->
) - Access Static Properties and Methods (
::
) - Access XHP Attributes (
->:
) - Create an Object (
new
) - Get the name of a class (
nameof
)
Built-in Type Operators
- Cast/Convert Types (
(int)
,(string)
, and more) - Check Types (
is
) - Enforce Types (
as
,?as
) - Index into Hack Arrays and Strings (
[]
) - String Concatenation (
.
) - Unpack Types (
list
)
Error Control Operators
Other Function Operators
- Async: Suspend Execution (
await
) - Coalesce: Non-Null Evaluation (
??
) - Echo: Write to Standard Output (
echo
) - Exit: Terminate a Function (
exit
) - Pipe: Chain Function Calls (
|>
then stored in$$
) - Ternary: Alternative
If
Evaluation (? :
,?:
) - Yield: Define a Generator (
yield
)
Thank You!
Thank You! If you'd like to share more feedback, please file an issue.