Avatar of Adam Jones
Adam Jones

asked on 

Adding a line break in PHP feed output

Hello

I am trying to edit a feed that is created for my blog extension. I want to place a line break after each tag (there is another problem with the feed and bugs are hard to find when it is all on one line) but I cannot get it to work. I have tried /n but this just outputs /n.

It is not echo so I am not sure this is correct to use. Here is the code

            $output  = '<?xml version="1.0" encoding="UTF-8" ?>';
            $output .= '<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom">';

Open in new window


I have tried

            $output  = '<?xml version="1.0" encoding="UTF-8" ?> /n';
            $output .= '<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom"> /n';

Open in new window


this just outputs

<?xml version="1.0" encoding="UTF-8" ?>/n<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom"> /n

I have also tried

            $output  = '<?xml version="1.0" encoding="UTF-8" ?>';
			$output  = "\n";
            $output .= '<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom">';
			$output  = "\n";

Open in new window


This makes these lines disappear and replaced with a single line break.

Can someone please give me some advice?

Many Thanks
PHPHTMLHTTP ProtocolXMLWeb Development

Avatar of undefined
Last Comment
Ray Paseur
ASKER CERTIFIED SOLUTION
Avatar of gr8gonzo
gr8gonzo
Flag of United States of America image

Blurred text
THIS SOLUTION IS ONLY AVAILABLE TO MEMBERS.
View this solution by signing up for a free trial.
Members can start a 7-Day free trial and enjoy unlimited access to the platform.
See Pricing Options
Start Free Trial
Avatar of Adam Jones
Adam Jones

ASKER

Thanks. Worked perfectly.
Avatar of Ray Paseur
Ray Paseur
Flag of United States of America image

Just a note for going forward, some OS do not use \n for the end-of-line character.  PHP has a context-aware, future-proof, end-of-line character available in a predefined constant: PHP_EOL
http://php.net/manual/en/reserved.constants.php
PHP
PHP

PHP is a widely-used server-side scripting language especially suited for web development, powering tens of millions of sites from Facebook to personal WordPress blogs. PHP is often paired with the MySQL relational database, but includes support for most other mainstream databases. By utilizing different Server APIs, PHP can work on many different web servers as a server-side scripting language.

125K
Questions
--
Followers
--
Top Experts
Get a personalized solution from industry experts
Ask the experts
Read over 600 more reviews

TRUSTED BY

IBM logoIntel logoMicrosoft logoUbisoft logoSAP logo
Qualcomm logoCitrix Systems logoWorkday logoErnst & Young logo
High performer badgeUsers love us badge
LinkedIn logoFacebook logoX logoInstagram logoTikTok logoYouTube logo