Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations biv343 on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

What program will format PHP scripts?

Status
Not open for further replies.

748323

Programmer
Dec 10, 2004
70
US
For example.


if (statement) {
block;
}

to :

if (statement) {
block;
}

Thanks.
 
This is called indenting.

I, Would not use a program that automagically indents for me, as some times there are exceptions.

I can not think of any examples, but it's really annoying if your programming, and the application you are using, is screwing with your code.

Some prefer syntax coloring, it's a bit "nicer" to look at, but I most of the time just program in my ftp client..

eg. I open the connection to my host, then I edit the file remotely and save it.

For windows, I think textpad is great.
it's like notepad, but it has more features, like syntax coloring (PERL), line-numbers, etc.

There is also an advanced version of notepad too, but I dont remember what it's called.

I think in *nix, a lot of people prefer vim.

I think that macromedia dreamweaver mx can be good for coding too, if you go to "coder view", but I think it takes up too much space if you have both code/design.

I dont like to have my windows more than maybe 80% of desktop-area. I dont know why, it might be something from windows 3 experiences :p


Olav Alexander Mjelde
Admin & Webmaster
 
btw. I forgot one thing.

There are several ways of indenting code..

some might do as:
if(foo) {bar;}

some prefer:
if (foo) {
bar;
}

And some:
if (foo)
{
bar;
}

you also have some small variances, like:
if (foo) {
bar;
}

so, I think that some automated indenting would be a bad idea, at least for me. I think that when you have learnt indenting, you do it without thinking about it. You must always indent in the same way, so you do not confuse others that are to read your code.

Also remember to comment your code. Do not comment too little, or too much.

if (foo) { // what to do
do;
} // end if (foo)

this is how I like to do it.

maybe you also want some comments by the functions, to describe what they actually do. I comment the end bracket of the if/else, etc. as if I have them nested, it's very easy to delete one too many or one too little of the brackets.. Then you suddenly have bracket-hell!

Olav Alexander Mjelde
Admin & Webmaster
 
EditPlus 2 is Free.

I don't know of any that will take un-indented code and indent it, because, as DaButcha said, there are many different ways people indent.

My personal choice is

Code:
funcName( $var ) {
    # code to follow
    echo 'something';
}

*cLFlaVA
----------------------------
[tt]insert funny quotation here.[/tt]
 
Zend Studio does this... highlight what you want indented, and let it go to town.

Emacs does this as well... you can either select and have it indent, or you can just press tab anywhere on the line and it'll do its job.

Both these programs will do the indenting only, so there's no problem with different styles... emacs in particular allows you to configure it to be precisely as you want... i.e. do you prefer
Code:
if ()
{
  abc;
}
or
if ()
  {
    abc;
  }

Outside of that, everything is pretty much automatic based on where you put your braces. Personally I like the way emacs does it better.

However, I'm not pleased with the way either program handles switch/case statements.
 
Use Crimson editor from it is freeware and has colour coding etc for many different script languages, php and perl included.

I have used it for a couple of years now, and find it great.

Rich
 
I use cuteftp pro, with perl coloring :p
sometimes, I dont bother using coloring at all..

eg. I program in pico (ssh), or in the ftp client.

Olav Alexander Mjelde
Admin & Webmaster
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top