Jump to content

newline \n not working for me


PlagueInfected

Recommended Posts

I've always had an issue with this kind of PHP

 

<?php    
$scr = $_SERVER['SCRIPT_FILENAME'];
           
              echo '<ul>\n';
               if ($scr == 'main.php') { 
               echo '<li><a class=\"onpage\" href=\"/main.php\">main</a></li>\n';
              }
            else {
              echo  '<li><a href=\"/main.php\">main</a></li>\n';
              }
              if ($scr == 'services.php') { 
                 echo '<li><a class=\"onpage\" href=\"/services.php">services</a></li>\n';
                }
             else {
                 echo '<li><a href=\"/services.php\">services</a></li>\n';
                }
                
                   if ($scr == 'portfolio.php') {
                  echo '<li><a class=\"onpage\" href=\"/portfolio.php\">portfolio</a></li>\n';
                 }
               else {
                 echo '<li><a href=\"/portfolio.php\">portfolio</a></li>\n';
                 }
                   if ($scr == 'blog.php') {
                  echo '<li><a class=\"onpage\" href=\"/blog.php\">blog</a></li>\n';
                 }
               else {
                  echo '<li><a href=\"/blog.php\">blog</a></li>\n';
                  }
                echo '</ul>\n';
            
?>

 

when it's outputting in HTML, is displays \n and does not do a line break.

 

I don't want to use the line break either to display my list properly either.

Link to comment
https://forums.phpfreaks.com/topic/183224-newline-n-not-working-for-me/
Share on other sites

yes, as the items are part of an Unordered list they will break onto a new line anyway.

 

However!!!!.....

 

If you assign a CSS class "Float" to your list it will display horizontally and you will need to use the nl2br() suggestion to display any vertical items.

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.