Do you know any php statement working like python's pass
views:
66answers:
3
+6
A:
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.
Chacha102
2010-05-17 21:02:26
i need it to use in ternary operator. `(condition?something:pass)`;`condition?something:` ends with error
Jan Tojnar
2010-05-17 21:08:49
@Jan Tojnar: Use an empty string `''`. If you use the ternary operator, you mostly assign a value to a variable. This will assign `false` then (empty string is false). If you do not use it for variable assignment, it what use a plain `if` statement. Much easier to understand then.
Felix Kling
2010-05-17 21:36:16
Can't you just use `result = condition ? something : result`?
kaloyan
2010-05-17 21:36:17
+4
A:
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.
Yacoby
2010-05-17 21:03:29