How does PHP implement the Generate VCF vcard file? This article mainly introduced the PHP implementation of the VCF vcard file function class definition and use method, combined with the specific example form analysis of the VCF vcard function class specific definition and use, and with the VCardIFL.class.php class file source for the reader to download the reference. Need friends can refer to, hope to help you.
The method of reading the VCF file by PHP is described earlier, and the method of generating VCF file is discussed here.
The VCF format is the business card storage format for Outlook in Windows systems, and opening the VCF format requires the appropriate companion software for your phone, and you can also open the VCF file by using Outlook.
The file format saved by phone Address Book is also in VCF format. Here is an example of using PHP to generate a VCF format file.
The specific code is as follows:
<?php date_default_timezone_set (' PRC '); Include ("VCardIFL.class.php"); $arData =array (); $arData ["FileName"]= ' 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.php.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"]= ' php@mail.com '; $arData ["Vcard_h_phon"]= ' 1388888888x '; $arData ["Vcard_h_zip"]= "; $arData ["Vcard_h_uri"]= ' http://php.cn '; $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"]= ' * * * * @mail. 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.***.com '; $vcfdemo =new VCARDIFL ($arData); $vcfdemo->createvcard (); echo $vcfdemo->savevcard ()? ' Create success! ': ' Creation failed! ';? >
Run the code to create a corresponding VCF_DEMO.VCF file under the Tmpfile folder, as shown in:
Related recommendations:
A detailed explanation of PHP XML file additions and deletions
A detailed explanation of how PHP implements the CSV file import database
A detailed explanation of how PHP exports the database to a CSV file