vcard php,php vcard显示为纯文本

我的网站上有一个新功能,允许用户获取vcard文件.此功能从我的数据库读取数据(这一个工作),并生成vcard.

该文件是:vcard.PHP,我将用户标识作为GET传递

然后我使用该ID获取所有信息

我的问题是当我想要获得vcard,它显示为文本.这是我的代码的简化版本:

class Vcard {

public function __construct() {

$this->props = array();

}

public function setName($family, $first) {

$name = $family . ';' . $first . ';';

$this->props['N'] = $name;

if(!isset($this->props['FN'])) {

$display = $first . ' ';

$display .= $family;

$this->props['FN'] = trim($name);

}

}

/* and all the rest of my props */

public function get() {

$text = 'BEGIN:VCARD' . "\r\n";

$text.= 'VERSION:2.1' . "\r\n";

foreach($this->props as $key => $value) {

$text .= $key . ':' . $value . "\r\n";

}

$text.= 'REV:' . date("Y-m-d") . chr(9) . date("H:i:s") . "\r\n";

$text.= 'MAILER:My VCard Generator' . "\r\n";

$text.= 'END:VCARD' . "\r\n";

return $text;

}

}

$v = new Vcard();

$v->setName('Smith', 'John');

echo $v->get();

代码工程,为什么它不能得到它作为vcard?

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值