4

介绍

我正在开发 PHP,NetBeans IDE 7.2 (Build 201207171143)我喜欢formatting以我的自定义格式清理我的代码。

目前,我与同事在一个小组中工作。我的一些同事习惯于编写不带大括号的单行语句(我认为这是不好的做法)。

例子

我的同事做什么:

<?php

     if($stackoverflow == 'Cool')
           echo 'Stack Overflow is Cool!';

?>

当我格式化代码时我想要什么。

<?php

     if($stackoverflow == 'Cool') {
           echo 'Stack Overflow is Cool!';
     }

?>

问题

所以我正在寻找的是实现这一目标的设置。我可以找到所有其他设置都有漂亮的牙套。

Tools -> Options -> Editor -> Formatting -> PHP

尝试了什么

我发现了这一点,但我认为这不是我想要实现的目标,因为他谈到了宏。

有人可以帮我解决这个问题吗?

4

5 回答 5

2

I am not sure if u have find the solution or not

Tools -> Options -> Editor -> Formatting
Language: PHP
Category: Braces

Select "same line" for all

于 2012-12-27T03:34:38.013 回答
0

同意共享的编码风格!不要依赖您的编辑器为您格式化和取消格式化代码。

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!

于 2012-12-10T13:16:43.027 回答
-1

Ok so it isn't possible I guess.

于 2013-01-14T09:35:40.287 回答
-1

It is possible to format braces in PHP.
This is an example:

enter image description here

于 2013-05-14T19:29:11.720 回答
-1

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".

Netbeans screenshot

于 2013-10-27T03:58:38.760 回答