Jump to content

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

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.