PHP實現(xiàn)生成vcf vcard文件功能類定義與使用方法詳解【附demo源碼下載】 原創(chuàng)
本文實例講述了PHP實現(xiàn)生成vcf vcard文件功能類定義與使用方法。分享給大家供大家參考,具體如下:
前面介紹了php讀取vcf文件的方法,這里再來研究一下vcf文件的生成方法。
VCF格式是Windows系統(tǒng)中outlook的名片存儲格式,打開VCF格式需要使用手機的相應配套軟件,使用outlook也可以打開VCF文件。
手機通訊錄保存的文件格式也是vcf格式。這里就來給出一個使用php生成vcf格式文件的實例。
具體代碼如下:
<?php
date_default_timezone_set('PRC');
include("VCardIFL.class.php");
$arData=array();
$arData["fileName"]='jb51_vcf_demo';
$arData["saveTo"]='tmpFile';
$arData["vcard_birtda"]=date('Y-m-d',time());
$arData["vcard_f_name"]='Tom';
$arData["vcard_s_name"]='Green';
$arData["vcard_uri"]='http://www.fzitv.net';
$arData["vcard_nickna"]='Coder';
$arData["vcard_note"]='Write Code';
$arData["vcard_cellul"]='1388888888x';
$arData["vcard_compan"]='Blue Best Comp';
$arData["vcard_p_pager"]='No';
$arData["vcard_c_mobile"]='1388888888x';
$arData["vcard_h_addr"]='Blue Best Comp';
$arData["vcard_h_city"]='XuZhou';
$arData["vcard_h_coun"]='China';
$arData["vcard_h_fax"]='No';
$arData["vcard_h_mail"]='jb51@fmail.com';
$arData["vcard_h_phon"]='1388888888x';
$arData["vcard_h_zip"]='jb51';
$arData["vcard_h_uri"]='http://tools.jb51.net';
$arData["vcard_w_addr"]='Star Shine';
$arData["vcard_w_city"]='Xuzhou';
$arData["vcard_w_coun"]='China';
$arData["vcard_w_fax"]='no';
$arData["vcard_w_mail"]='StarShine@fmail.com';
$arData["vcard_w_phon"]='1366666666X';
$arData["vcard_w_role"]='Boss';
$arData["vcard_w_titl"]='Demo test';
$arData["vcard_w_zip"]='StarZip';
$arData["vcard_w_uri"]='http://www.SimpleTest.com';
$vcfdemo=new VCardIFL($arData);
$vcfdemo->createVcard();
echo $vcfdemo->SaveVcard()?'創(chuàng)建成功!':'創(chuàng)建失敗!';
?>
運行代碼可在tmpFile文件夾下創(chuàng)建一個相應的jb51_vcf_demo.vcf文件,如下圖所示:

附:VCardIFL.class.php完整代碼點擊此處本站下載。
更多關于PHP相關內(nèi)容感興趣的讀者可查看本站專題:《php文件操作總結》、《PHP數(shù)組(Array)操作技巧大全》、《PHP基本語法入門教程》、《php面向對象程序設計入門教程》、《PHP網(wǎng)絡編程技巧總結》及《php字符串(string)用法總結》
希望本文所述對大家PHP程序設計有所幫助。
相關文章
解析將多維數(shù)組轉換為支持curl提交的一維數(shù)組格式
本篇文章是對將多維數(shù)組轉換為支持curl提交的一維數(shù)組格式實現(xiàn)代碼進行了詳細的分析介紹,需要的朋友參考下2013-07-07
php實現(xiàn)壓縮合并js的方法【附demo源碼下載】
這篇文章主要介紹了php實現(xiàn)壓縮合并js的方法,涉及php壓縮文件類JSMin的相關調(diào)用與使用技巧,并附帶了完整的demo源碼供讀者下載參考,需要的朋友可以參考下2016-09-09

