Jump to content

Proper Markup Reference?


dtyson2000

Recommended Posts

Hi everybody...

 

I've recently decided to clean up the mess that is my php coding. It's all over the place and I can't keep doing it this way. Does anybody have a reference they would like to share for proper php markup, spacing, etc.? I search around but find bits and pieces of things on various sites.

 

I would really appreciate it.

 

Thanks!

Link to comment
https://forums.phpfreaks.com/topic/113009-proper-markup-reference/
Share on other sites

Consistency is the key, pick a method you like and stick to it.

 

Having said that, most frameworks usually have some form of 'coding standard' detailed in there documentation somewhere, maybe take a look at one of them? Really though, its personal preference and as long as your consistent, it should remain easy enough to follow.

Not necessarily thorpe. I remember a person from here that used to consistently write code without any white-space whatsoever. That wasn't readable nor easy to follow ;)

 

Generally, it's pretty standard to go one indention level in at an opening curly bracket and go one indention level out when you close it again. Also, some people like the opening bracket on the same line as the preceding statement, some like it on a line below by itself. Some people use a space between a function call or a keyword and a succeeding parenthesized statement or argument list. Some people add spacing after commas like one would do in a natural language (e.g. English) for things that are separated by commas. Some people add spacing around the concatenation operator (dot (.)). Some people like to use a fixed amount of spaces instead of the tab character (usually four).

 

There are many ways, but there is no best way (although there are some ways I would say look horrible and are difficult to follow).

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.