Page 2 of 2 FirstFirst 12
Results 11 to 20 of 20

Thread: Comment your code

  1. #11
    Join Date
    Feb 2007
    Location
    🌎
    Posts
    528
    Thanks
    10
    Thanked 10 Times in 10 Posts
    Blog Entries
    2

    Default

    1 character = 1 byte
    ....(o_ Penguins
    .---/(o_- techno_racing
    +(---//\-' in
    .+(_)--(_)' The McMurdo 500

  2. #12
    Join Date
    Jun 2005
    Location
    英国
    Posts
    11,878
    Thanks
    1
    Thanked 180 Times in 172 Posts
    Blog Entries
    2

    Default

    No, there's rarely a reason to do that. If a function contains a lot of complex code that can't be easily understood, there's a handy way to label it: abstract it out into other functions, with descriptive names.

    There's one exception, of course, which is when writing embedded documentation for parsing by tools like PHPDoc, JSDoc. JavaDoc, Doxygen, Haddock, &c.

    The # comment form in PHP is discouraged by PECL style guides. Refrain from using it.
    Twey | I understand English | 日本語が分かります | mi jimpe fi le jbobau | mi esperanton komprenas | je comprends franšais | entiendo espa˝ol | t˘i Ýt hiểu tiếng Việt | ich verstehe ein bisschen Deutsch | beware XHTML | common coding mistakes | tutorials | various stuff | argh PHP!

  3. #13
    Join Date
    Sep 2005
    Posts
    882
    Thanks
    0
    Thanked 3 Times in 3 Posts

    Default

    How about SQL? No one ever seems to comment their queries...

    Single line
    Code:
    SELECT * FROM some_table--Comment
    Multiline
    Code:
    SELECT *
    /* Comment
    goes here*/
    FROM some_table

  4. #14
    Join Date
    Jul 2006
    Location
    Canada
    Posts
    2,581
    Thanks
    13
    Thanked 28 Times in 28 Posts

    Default

    I guess it just doesn't seem feasible to most people... I never thought of using comments in SQL queries because I always looked at them as strings (in PHP), so I didn't think you could use a comment. I didn't realize that SQL had its own commenting system.
    - Mike

  5. #15
    Join Date
    Jan 2008
    Posts
    4,167
    Thanks
    28
    Thanked 628 Times in 624 Posts
    Blog Entries
    1

    Default

    Me too, and if anything. I'd just comment it out in the php, after the string. It also makes it look untidy, like Twey said in his first post in this topic.
    Jeremy | jfein.net

  6. #16
    Join Date
    Apr 2006
    Posts
    429
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    quite informative.
    Please don't mind me. I am just posting a lot of nonsense.

  7. #17
    Join Date
    Jun 2005
    Location
    英国
    Posts
    11,878
    Thanks
    1
    Thanked 180 Times in 172 Posts
    Blog Entries
    2

    Default

    SQL comments aren't usually used in tiny strings of code like those you probably use embedded in your PHP. They're used for things like big tables stored in separate files, or large stored procedures.
    Twey | I understand English | 日本語が分かります | mi jimpe fi le jbobau | mi esperanton komprenas | je comprends franšais | entiendo espa˝ol | t˘i Ýt hiểu tiếng Việt | ich verstehe ein bisschen Deutsch | beware XHTML | common coding mistakes | tutorials | various stuff | argh PHP!

  8. #18
    Join Date
    Feb 2007
    Location
    🌎
    Posts
    528
    Thanks
    10
    Thanked 10 Times in 10 Posts
    Blog Entries
    2

    Default

    Code:
    _This is another type of comment in CSS.
    _It both saves you one byte over //
    _AND is not recognized as a comment by IE.
    _Think about how useful that could be!
    ....(o_ Penguins
    .---/(o_- techno_racing
    +(---//\-' in
    .+(_)--(_)' The McMurdo 500

  9. #19
    Join Date
    Jun 2008
    Posts
    589
    Thanks
    13
    Thanked 54 Times in 54 Posts
    Blog Entries
    1

    Default

    Would it be very useful if it isn't recognized as a comment in IE? I really didn't know if you were being sarcastic or not...

    -magicyte

  10. #20
    Join Date
    Jun 2005
    Location
    英国
    Posts
    11,878
    Thanks
    1
    Thanked 180 Times in 172 Posts
    Blog Entries
    2

    Default

    It's useful for IE hacks. Conditional comments are vastly preferable, though.
    Twey | I understand English | 日本語が分かります | mi jimpe fi le jbobau | mi esperanton komprenas | je comprends franšais | entiendo espa˝ol | t˘i Ýt hiểu tiếng Việt | ich verstehe ein bisschen Deutsch | beware XHTML | common coding mistakes | tutorials | various stuff | argh PHP!

Tags for this Thread

Bookmarks

Posting Permissions

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