PHP Syntax Formatting - Page 6
Page 6 of 6 FirstFirst ... 456
Results 76 to 85 of 85

Thread: PHP Syntax Formatting

  1. #76
    ... dream in PHP...
    Join Date
    Apr 2012
    Posts
    1
    Quote Originally Posted by Horizon88 View Post
    I'd like to note that, on my system at least, when I'm posting code manually here and hit Tab it skips on to the submit button, or the next field in the form, so if you're posting a sizable chunk of code manually, perhaps do it in Notepad or another simple text editor beforehand and then paste it in.
    What's wrong with using an IDE that formats it for you and then paste it into the field. Instead of using Notepad why not use Netbeans?

  2. #77
    Settled 4 red convertible dalecosp's Avatar
    Join Date
    Jul 2002
    Location
    Accelerating Windows at 9.81 m/s....
    Posts
    8,493
    Quote Originally Posted by Bonesnap View Post
    My eyes are bad so I code in size 14pt font.
    I've been setting my terminals to that a lot more often of late ... *sigh*.
    /!!\ mysql_ is deprecated --- don't use it! Tell your hosting company you will switch if they don't upgrade! /!!!\ ereg() is deprecated --- don't use it!

    dalecosp "God doesn't play dice." --- Einstein "Perl is hardly a paragon of beautiful syntax." --- Weedpacket

    Getting Help at All --- Collected Solutions to Common Problems --- Debugging 101 --- Unanswered Posts --- OMBE: Office Machines, Business Equipment

  3. #78
    Senior Member
    Join Date
    Mar 2009
    Posts
    1,153
    Quote Originally Posted by dalecosp View Post
    I've been setting my terminals to that a lot more often of late ... *sigh*.
    I'm only 27...

    Though since switching to Komodo Edit I've actually gone down one size and now code at 13pt size, though there are times I'd like to increase it.
    Declare variables, not war.

  4. #79
    Junior Member
    Join Date
    Feb 2004
    Location
    Mumbai
    Posts
    5
    Write down like below this is proper way to write code::
    // Correctly spacing a class with tabs to make it readable.
    class foo{
    public $somthing;

    function __construct(){
    // Constructor
    }

    public function bar($bool){
    if ($bool == true)
    {
    $this->something = true;
    }

    return $this->something;
    }
    }

  5. #80
    PHP Witch laserlight's Avatar
    Join Date
    Apr 2003
    Location
    Singapore
    Posts
    13,913
    kamlesh, please post PHP code in [php][/php] bbcode tags and other code in [code][/code] bbcode tags. Otherwise, your nicely formatted code looks like it completely lacks proper indentation

    By the way:
    PHP Code:
    if ($bool == true
    Yuck!
    Use Bazaar for your version control system
    Read the PHP Spellbook
    Learn How To Ask Questions The Smart Way

  6. #81
    Senior Member
    Join Date
    Sep 2011
    Posts
    258
    Quote Originally Posted by kamlesh View Post
    Write down like below this is proper way to write code::
    PHP Code:
    // Correctly spacing a class with tabs to make it readable.
    class foo{
        public 
    $somthing;
        
        function 
    __construct(){
            
    // Constructor
        
    }
        
        public function 
    bar($bool){
            if (
    $bool == true)
            {
                
    $this->something true;
            }
            
            return 
    $this->something;
        }

    Yeah its true, poor spacing of php blocks makes it difficult to read.

  7. #82
    Senior Member traq's Avatar
    Join Date
    Jun 2011
    Location
    so.Cal
    Posts
    949
    Quote Originally Posted by kamlesh View Post
    PHP Code:
    <?php // Correctly spacing a class with tabs to make it readable.
    class foo{
        public 
    $somthing;
        
        public function 
    bar($bool){ // <-- { on same line
            
    if ($bool == true)
            { 
    //                       <-- { on following line ...?
                
    $this->something true;
            }
            
            return 
    $this->something;
        }
    }
    ...

  8. #83
    Pedantic Curmudgeon Weedpacket's Avatar
    Join Date
    Aug 2002
    Location
    General Contact Unit "Coping Mechanism"
    Posts
    22,505
    Quote Originally Posted by traq View Post
    ...
    I've seen something like this, though the other way around: braces that are syntactically required (around class and function bodies, for example) get their own lines, while statement blocks use 1TBS.

    PHP Code:
     <?php
    class foo
    {
        public 
    $somthing// $something?
        
        
    public function bar($bool)
        {
            if (
    $bool == true) {
                
    $this->something true;
            }
            
            return 
    $this->something;
        }
    }
    Last edited by Weedpacket; 09-23-2012 at 10:11 PM.
    THERE IS AS YET INSUFFICIENT DATA FOR A MEANINGFUL ANSWER
    FAQs! FAQs! FAQs! Most forums have them!
    Search - Debugging 101 - Collected Solutions - General Guidelines - Getting help at all

  9. #84
    Junior Member
    Join Date
    Aug 2016
    Posts
    1
    inter alia, coding style gives others an impression about the author.

    ---------------------
    Canadas Experts in web development:
    www.webiprog.ca

  10. #85
    Not Yet Involved Shrike's Avatar
    Join Date
    Oct 2003
    Location
    The Eighth, Sursamen
    Posts
    2,278
    http://www.php-fig.org/psr/psr-1/

    Holiday good so far as possible and the other day that I am not giving up gin.

    Stupid auto correct.
    The Hundredth Idiot

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •