Skip to main content

This site requires you to update your browser. Your browsing experience maybe affected by not having the most up to date version.

We've moved the forum!

Please use forum.silverstripe.org for any new questions (announcement).
The forum archive will stick around, but will be read only.

You can also use our Slack channel or StackOverflow to ask for help.
Check out our community overview for more options to contribute.

Archive /

Our old forums are still available as a read-only archive.

Moderators: martimiz, Sean, Ed, biapar, Willr, Ingo

Question on Coding Conventions


Go to End


5 Posts   1418 Views

Avatar
Double-A-Ron

Community Member, 607 Posts

23 September 2008 at 1:25pm

Edited: 23/09/2008 1:25pm

http://doc.silverstripe.com/doku.php?id=coding-conventions

Quote:

Don’t end them with ?> - if you leave it out, it’s implied and it prevents blank lines from accidentally being outputted when you have newlines after the ?>

I understand this. I use this method all the time with standard PHP includes. But I am unsure when it comes to how SS processes php files.

I mean, should this rule apply to Page Types or DataObject files I create in /mysite/?

Does it apply everywhere an extender or module developer uses PHP? I've always been under the impression, that in roll-your-own php apps, this method should only be used on included php files, not primary pages that a user might view directly. (I may have misunderstood this)

Cheers
Aaron Cooper

Avatar
Fuzz10

Community Member, 791 Posts

23 September 2008 at 10:56pm

Hmmm.. good question! ;-)

Subscribe....

Avatar
ajshort

Community Member, 244 Posts

23 September 2008 at 11:53pm

Edited: 23/09/2008 11:54pm

Im fairly sure that this rule is just a good practice to use on every file that is purely PHP. It helps to prevent the "header has already been sent" messages and stuff.

Avatar
Ingo

Forum Moderator, 801 Posts

25 September 2008 at 10:46pm

I don't think we should have coding conventions with "exceptions", so yeah, if its written there it should apply consistently for all PHP files you create. I'm more in favor of actually checking your code for trailing blanks and close your tags properly btw, but thats not what the conventions state ;)

Avatar
Double-A-Ron

Community Member, 607 Posts

25 September 2008 at 11:14pm

Thanks for the clarification guys.

Aaron