WordPress.org

Ready to get started?Download WordPress

Forums

[resolved] [closed] No PHP closing tag in config file? (9 posts)

  1. complaintbucket
    Member
    Posted 5 years ago #

    greetings,

    Ok, maybe I'm going to look like a fool; however, I like to learn new things. Why is there PHP NO closing tag in wp-config.php?

    Thanks.

  2. darrinb
    Member
    Posted 5 years ago #

    There is in mine.

  3. nast0
    Member
    Posted 5 years ago #

    Same here, and there should be too. There's also one in the config-sample file...

  4. Mark / t31os
    Moderator
    Posted 5 years ago #

    You don't need to have a closing tag for PHP files..

    In some cases it's considered good practice to leave the closing tag out.

  5. esmi
    Forum Moderator
    Posted 5 years ago #

    Really? When?

  6. Mark / t31os
    Moderator
    Posted 5 years ago #

    When you are distributing files and can expect users to be using dodgy editors that add extra lines or erroneous spaces on the end of files..... and such.....

    It's quite easy for extra spaces to end up on the end of a file, and if you're using several includes tracking these spaces down can be a pain, especially if you're dealing with lots of files... spaces after closing PHP tags is known to cause various issues including invalid headers...

    Of course there are cases when not using closing tags causes problems to, so it's catch 22...

  7. Cheung Tat Ming
    Member
    Posted 5 years ago #

    me too,no close tag, but is it accept on old php version?

  8. S.S.Senthil Kumar
    Member
    Posted 5 years ago #

    Not using the closing tag is one of the recommended PHP coding practice. like t31os_ told. great explanation dude :-bd

  9. activeblogging
    Member
    Posted 4 years ago #

    It's optional, and safe to leave off - plus you save quite a few headaches removing it from wp-config.php. If it's good enough for PHP.net, Drupal, and Zend, it's good enough for me.

    [moderated--link removed.]

Topic Closed

This topic has been closed to new replies.

About this Topic