File: ExportTest.php

Recommend this page to a friend!
  Classes of Stefan Kientzler  >  PHP vCard Library  >  ExportTest.php  >  Download  
File: ExportTest.php
Role: Example script
Content type: text/plain
Description: Test for Export vCard
Class: PHP vCard Library
Import and export contact lists in vCard format
Author: By
Last change: renamed namespace

- renamed namespace to fit PSR-4 recommendations for autoloading.
- replaced TAB with spaces
repositiory created
Date: 3 months ago
Size: 2,135 bytes


Class file image Download
use SKien\VCard\VCard;

$oVCard = new VCard();

// just create new contact
$oContact = new VCardContact();
$oContact->setName('von Flake', 'Wiki');
$oContact->setOrganisation('Company 4711');
$oAddress = new VCardAddress();
$oAddress->setStr('Bärenweg. 4');
$oContact->addAddress($oAddress, true);
$oContact->addPhone('01234 5678', VCard::HOME, false);
$oContact->addPhone('0123 89765456', VCard::CELL, true);

$oAddress = new VCardAddress();
$oAddress->setStr('Companystr. 8');
$oContact->addAddress($oAddress, false);

$oContact->addPhone('01234 98356', VCard::WORK, false);
$oContact->addEMail('', true);
$oContact->addEMail('', false);
$oContact->addEMail('', false);
$strNote = "Hier steht ein mehrzeiliger Text," . PHP_EOL;
$strNote .= "der auch Umlaute (ä,ö,ü) und Sonderzeichen" . PHP_EOL;
$strNote .= "(@,~,§,$) enthä....";

// insert multiple contacts
$oContact->setPortraitBlob($blobPortrait); // Wiki von Flake
// change name and portrait
$oContact->setName('von Flake', 'Ilvy');
$oContact->setPortraitFile('images/sample2.png'); // Ilvy von Flake
// change name again and add some additional info....
$oContact->setName('von Flake', 'Halvar');
$oContact->setPortraitFile('images/sample3.bmp'); // Halvar von Flake

// and write to file
$oVCard->write('test.vcf', false);

For more information send a message to info at phpclasses dot org.