What is the equivalent in PHP for Python's pass statement?
-
27-09-2019 - |
Question
Do you know any PHP statement that works like Python's pass
statement?
Solution
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.
OTHER TIPS
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.
Can't you just use a semicolon?
if ( $x == $y )
;
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow