PHP 中 Python 的 pass 语句的等价物是什么?
您知道任何与 Python 的 pass
语句类似的 PHP 语句吗?
Do you know any PHP statement that works like Python's pass
statement?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(7)
只需将括号留空即可...
Python 有密码,因为它们不使用括号来定义类、函数和其他语句的主体部分。 PHP 不存在这种困境,因此不需要说明主体语句为空。
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.
PHP 中不需要它。 Python 代码:
只需将括号留空即可用 PHP 编写
这同样适用于需要括号的其他 PHP 构造,例如类或函数。
It isn't needed in PHP. The Python code:
Can be written in PHP by just leaving the brackets empty
The same applies to other PHP constructs requiring brackets such as classes or functions.
不能只用分号吗?
Can't you just use a semicolon?
当需要可读性时,您可以使用
When needed for readability you could use
语法检查器和 linter 变得越来越擅长发出无用代码块的信号,即使这是开发人员的自愿行为。
有时,原生 do_nothing() 函数会非常好且可读。
为了避免语法检查器强调警报,我使用:
The syntax checkers and linters are becoming more and more good at signaling not useful block of codes, also when this is a voluntary action of the developer.
A
native do_nothing()
function would be very nice and readable sometimes.To avoid stressing alerts from syntax checkers, I use:
NULL 是 python 中 pass 的替代品
NULL is the alternative for pass in python
您可以使用“goto”不一样,但它可以提供帮助。
欲了解更多信息:
https://www.php.net/manual/en/control-结构.goto.php
You can use "goto" is not the same but it can help.
For more infos:
https://www.php.net/manual/en/control-structures.goto.php