SitePoint Sponsor

User Tag List

Results 1 to 3 of 3

Thread: PHP Line Breaks

  1. #1
    Non-Member
    Join Date
    Jan 2004
    Location
    Seattle
    Posts
    4,328
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    PHP Line Breaks

    I'm working on a CMS with lots of PHP includes, and I noticed that my html has become very disorderly. Consider, the following html:

    PHP Code:
    <div>Text
    // Included File
    <!--BeginAds-->
    ADS
    <!--EndAds-->
    // End Included File
    </div>
    <
    div>Text</div
    That's what I want it to look like, but it might actually look something like this:

    PHP Code:
    <div>Text<!--BeginAds-->
    ADS
    <!--EndAds--></div>
    <
    div>Text</div
    I believe there are various symbols that people use as "line breaks" in PHP. What's the proper way to format my include so that it doesn't merge with the html above or below it when I view the source code? I assume I would have to convert this...

    PHP Code:
    <!--BeginAds-->
    ADS
    <!--EndAds--> 
    to this...

    PHP Code:
    <?php
    <!--BeginAds-->
    ADS
    <!--EndAds-->
    ?>
    Or can I insert the line break in the include link?:

    PHP Code:
    <?php include($_SERVER['DOCUMENT_ROOT'] . '/files/ads.php'); ?>
    Thanks.

  2. #2
    SitePoint Member auveeb's Avatar
    Join Date
    Oct 2005
    Location
    NY, USA
    Posts
    0
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    \n can be used for linebreaks. You could probably do something like:
    PHP Code:
    <?php
    include($files); echo "\n";
    ?>

  3. #3
    Non-Member
    Join Date
    Jan 2004
    Location
    Seattle
    Posts
    4,328
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Thanks. This is perfect:

    PHP Code:
    echo "\n"; include($_SERVER['DOCUMENT_ROOT'] . '/file.php'); echo "\n"


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
  •