gpt4 book ai didi

PHP:iCal 创作,如何在描述中换行

转载 作者:塔克拉玛干 更新时间:2023-11-03 06:01:31 27 4
gpt4 key购买 nike

我正在使用以下代码为 php 脚本创建 outlook 的日历邀请。但是\n 并没有给我一个新的 outlook 行。有没有办法做到这一点?如果你不能,那似乎很愚蠢!

  function addToCalendar($calEmail, $calSubject, $calDesc) 
{

$calEmail = 'freelance@skinzy.org';
$description = $calDesc;
$message="BEGIN:VCALENDAR
VERSION:2.0
CALSCALE:GREGORIAN
METHOD:REQUEST
BEGIN:VEVENT
DTSTART:20110718T121000Z
DTEND:20110718T131000Z
DTSTAMP:20110525T075116Z
ORGANIZER;CN=TOMS TEST:mailto:system@skinzy.org
UID:12345678
ATTENDEE;PARTSTAT=NEEDS-ACTION;RSVP= TRUE;CN=Yup:mailto:sample@test.com
DESCRIPTION New \n Line
LOCATION: I AM THE LOCATION
SEQUENCE:0
STATUS:CONFIRMED
SUMMARY: TEST SUMMARY
TRANSP:OPAQUE
END:VEVENT
END:VCALENDAR";

$headers = "From: From Name <From Mail>\n";
$headers .= "MIME-Version: 1.0\n";
$headers .= "Content-Type: text/calendar; method=REQUEST;\n";
$headers .= ' charset="UTF-8"';
$headers .= "\n";
$headers .= "Content-Transfer-Encoding: 7bit";


$subject = "Meeting Subject";
$subject = html_entity_decode($calSubject, ENT_QUOTES, 'UTF-8');


if(mail($calEmail, $calSubject, $message, $headers)) {

echo "sent";
}else {
echo "error";
}


}

这是我遇到问题的 DESCRIPTION New\n Line 部分。

任何帮助将不胜感激

汤姆

最佳答案

您应该将\r\n 替换为\n:

$description = str_replace("\r\n", "\\n", $description);

另见 Encoding newlines in iCal files

关于PHP:iCal 创作,如何在描述中换行,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/8855606/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com