phpicalendarvcalendarvcal

No linebreaks in vcalendar file when echoing values with PHP


I have a vcalendar file. It works perfect if i type it between php tags like this

?>


BEGIN:VEVENT
DTSTART;VALUE=DATE:20110422
DTEND;VALUE=DATE:20120529
DTSTAMP:20120529T124028Z
UID:7a6db67f3edff4729956c47ec@calendarlabs.com
CREATED:20111213T123901Z
DESCRIPTION:Visit http://www.calendarlabs.com/holidays/ to know more about New Year's Day and for any other calendar needs.
LAST-MODIFIED:20111213T123901Z
LOCATION:
SEQUENCE:0
STATUS:CONFIRMED
SUMMARY:New Year's Day
TRANSP:TRANSPARENT
END:VEVENT


 <?php

 echo :

However, soon as i put it in echo statements like so:

 echo "BEGIN:VEVENT"; 

then it doesn't work. I have tried adding \n,
everything.

Also doesnt work if i do something like:

   DTSTART;VALUE=DATE:<?php echo $date; ?>

Can anybody else see a solution here?


Solution

  • PHP's closing tag eats whitespace following it. If you want to preserve newlines when outputting with PHP, you will need to do one of the following: