We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 17544
    • 86 Posts
    PEAR Standard can be found here
    http://www.go-pear.org/manual/en/standards.php

    Classic Coding Guidelines is as explained here
    http://www.evolt.org/article/PHP_coding_guidelines/18/60247/
      • 16885
      • 255 Posts
      I’m usually using a mix of those two, more the ’JAVA’ style as that is the way I need to write my code at school wink
        • 4018
        • 1,131 Posts
        Handsdown...PEAR-style! Just the placement of braces alone make the code easier to read. Spaces are used instead of tabs simply because some command-line text editors don’t support them well thus spaces are more consistent in the long run. I don’t see any problem with using upper-case letters in a variable name other than the fact that if you forget that you used a upper-case letter then you might run into trouble. Being consistent with how you use upper-case letters in variable and function names is very important for obvious reasons. All in all, I think using more of the PEAR-style techniques leads to more manageable code that works well on all platforms. smiley

        Jeff
          Jeff Whitfield

          "I like my coffee hot and strong, like I like my women, hot and strong... with a spoon in them."
          • 17544
          • 86 Posts
          The one weird thing I notice is all core PHP functions are using classic style like add_slashes(), mysql_connect() ... then it comes the PEAR that make it totally opposite, so it end up our PHP codes now are a mixed of both. Also for the open brace, having it on a line alone allow easy matching for the closing brace. Which coding style, is still up to one preferences smiley
            • 22303 MODX Staff
            • 10,725 Posts
            FYI, this poll is useless in terms of trying to get MODx to adopt a coding standard. I’ve discussed this before.

            As implied by my signature, I have a bit of aversion to the bountiful number of modern laws, and coding standards are among them. Don’t even get me started on PEAR. Anyway, everyone has their own favorite quirky approaches to formatting the code. The rule of thumb I live by here is this: respect the author’s code formatting, unless he has applied no consistent formatting to the code.

            If anything occurs in the area of code formatting standards on the MODx project, it will occur at the SVN repository check-in level; this will allow you to reformat it however you want when you check it out to edit it. It’ll be forced back to the proper format when you commit.

            As for variable names and such; just don’t use abbreviations and shorthand and we’ll all be able to understand the code better, without a bunch of rules to remember or redundant comments interspersed.

            But then again, these are just opinions.
              • 28042 ☆ A M B ☆
              • 24,524 Posts
              Indeed, downloadFile($fileName) or download_file($file_name)... not much difference there as far as understanding what the function is supposed to do.
                Studying MODX in the desert - http://sottwell.com
                Tips and Tricks from the MODX Forums and Slack Channels - http://modxcookbook.com
                Join the Slack Community - http://modx.org
                • 33372
                • 1,611 Posts
                "studly caps" - hee hee hee laugh

                I guess I use a mix also. I don’t much like underscores in variable and function names myself, but sometimes they can be more readable (especially for groups of vars, e.g. customer_name, customer_phone, customer_email and admin_name, admin_phone, admin_email). Some things, like proper indentation, make a huge difference in readability though.

                There are some other really good reminders in those links, including using single quotes, constants, and shortcut operators whenever possible.

                But my real interest in this discussion is to ask those of you who use Windows what programs you recommend for writing PHP and XHTML/CSS/JavaScript code. I am back using Rapid PHP after trying a few other apps with some nice extras features but that seemed to slow me down overall. But I’m not 100% satisfied with it (especially its clunky search and replace and project/library management), so I’m trolling for suggestions.

                Anyone have an application that they really like for Windows?
                  "Things are not what they appear to be; nor are they otherwise." - Buddha

                  "Well, gee, Buddha - that wasn't very helpful..." - ZAP

                  Useful MODx links: documentation | wiki | forum guidelines | bugs & requests | info you should include with your post | commercial support options
                  • 26439
                  • 104 Posts
                  Quote from: Bravado at Nov 25, 2006, 09:02 AM

                  Handsdown...PEAR-style! Just the placement of braces alone make the code easier to read.

                  I just think I got sold on the evolt method..... Where to put braces
                    • 33372
                    • 1,611 Posts
                    Quote from: ZAP at Nov 25, 2006, 01:44 PM

                    Anyone have an application that they really like for Windows?

                    Still wondering about this...

                    Anyone tried Zend Studio (http://www.zend.com/products/zend_studio)?

                    I can’t decide whether to use a full development platform or stick with something simpler.
                      "Things are not what they appear to be; nor are they otherwise." - Buddha

                      "Well, gee, Buddha - that wasn't very helpful..." - ZAP

                      Useful MODx links: documentation | wiki | forum guidelines | bugs & requests | info you should include with your post | commercial support options
                      • 17544
                      • 86 Posts
                      I use Zend Studio. Its syntax checking, auto-completion and debugging feature are very powerful. You can install the zend studio server and toolbar for your browser (ie or firefox) and you can actually debug at server stage, setting breakpoints, changing values, etc.

                      I personally like the auto-completion very much because it complete everything from php build-in functions, your own functions name, variables, objects members, etc. Also you can easily access to the PHP manual for a function after typing the function name at the help icon.

                      Worth using. Go get the trial, Zend Studio 5 just came out.