[英]Netbeans code format braces in PHP single line statements
Im developing PHP in NetBeans IDE 7.2 (Build 201207171143)
and I love the formatting
to clean up my code in my custom format. 我正在
NetBeans IDE 7.2 (Build 201207171143)
开发PHP,我喜欢这种formatting
以自定义格式清除代码。
At the moment I work in a group with colleagues. 此刻,我与同事们一起工作。 Some of my colleagues are used to write single line statement without braces (I think this is bad practice).
我的一些同事习惯于不使用大括号写单行语句(我认为这是不好的做法)。
What my colleagues do: 我的同事做什么:
<?php
if($stackoverflow == 'Cool')
echo 'Stack Overflow is Cool!';
?>
What I want when I format the code. 格式化代码时需要什么。
<?php
if($stackoverflow == 'Cool') {
echo 'Stack Overflow is Cool!';
}
?>
So what I am looking for is the setting to achieve this. 所以我正在寻找实现这一目标的设置。 I can find every other setting to have nice braces.
我可以找到其他所有设置都有不错的花括号。
Tools -> Options -> Editor -> Formatting -> PHP
I have found this but I think this isn't the way for what I want to achieve since he talks about macros. 我已经找到了这一点,但是我认为这不是我要实现的目标,因为他谈论宏。
Could someone help me with this? 有人可以帮我吗?
I am not sure if u have find the solution or not 我不确定您是否找到解决方案
Tools -> Options -> Editor -> Formatting 工具->选项->编辑器->格式化
Language: PHP 语言:PHP
Category: Braces 分类:大括号
Select "same line" for all 为所有选择“同一行”
Agree on a shared coding style! 同意共享的编码风格! Don't rely on your editor to format and unformat code for you.
不要依靠您的编辑器来为您格式化和取消格式化代码。
As for this example, I would argue that using brackets is better since it's less error prone - but this is something you have to agree upon with your collegues! 对于此示例,我认为使用方括号会更好,因为它不容易出错-但这是您必须与同事们达成共识的事情!
好的,所以我猜不可能。
It is possible to format braces in PHP. 可以在PHP中格式化花括号。
This is an example: 这是一个例子:
I finally found the answer to this. 我终于找到了答案。 It is found under Options -> Editor -> Formatting -> select PHP under the language drop down -> select "Wrapping" category -> scroll down to see "If Statement" and select "Never".
它位于选项->编辑器->格式->在语言下拉菜单中选择PHP->选择“包装”类别->向下滚动以查看“ If语句”,然后选择“从不”。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.