Do you know any PHP statement that works like Python's pass
statement?
PHP supports passing arguments by value (the default), passing by reference, and default argument values. Variable-length argument lists and Named Arguments are also supported.
With Python >= 3.0, you should use ... (Ellipsis) instead of pass to indicate "finish later" blocks.
Python pass Statement The pass statement is used as a placeholder for future code. When the pass statement is executed, nothing happens, but you avoid getting an error when empty code is not allowed. Empty code is not allowed in loops, function definitions, class definitions, or in if statements.
Python's pass mainly exists because in Python whitespace matters within a block. In Javascript, the equivalent would be putting nothing within the block, i.e. {} .
Just leave the bracket's empty...
Python has the pass word because they don't use brackets to define the body part of classes, function, and other statement. PHP doesn't have this dilemma , and therefore doesn't need something to say that a body statement is empty.
It isn't needed in PHP. The Python code:
if x == y: pass
Can be written in PHP by just leaving the brackets empty
if ( x == y ){ }
The same applies to other PHP constructs requiring brackets such as classes or functions.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With