PHP code example of badtudou / me-card
1. Go to this page and download the library: Download badtudou/me-card library. Choose the download type require. 2. Extract the ZIP file and open the index.php. 3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
badtudou / me-card example snippets
use BadTudou\MeCard\MeCard;
public function testReader()
{
$data = 'MECARD:N:Mike;TEL:123 4567 8901;;';
$mecard = BadTudou\MeCard\Reader::read($data);
/* or
$data = 'MECARD:N:Mike;TEL:123 4567 8901;;';
$mecard = new BadTudou\MeCard\MeCard($data);
$mecard->get();
*/
/*
[
"N" => "Mike",
"TEL" => "123 4567 8901",
]
*/
}
public function testSerialize()
{
$data = 'MECARD:N:Mike;TEL:123 4567 8901;;';
$mecard = new BadTudou\MeCard\MeCard($data);
$mecard->serialize();
/*
"MECARD:N:Mike;TEL:123 4567 8901;;"
*/
}
public function testSetAndGet()
{
$data = 'MECARD:N:Mike;TEL:123 4567 8901;;';
$mecard = new BadTudou\MeCard\MeCard($data);
$mecard->get('N');
/*
"Mike"
*/
$mecard->set('N', 'Jane');
$mecard->get('N');
/*
"Jane"
*/
$mecard->get();
/*
[
"N" => "Jane",
"TEL" => "123 4567 8901",
]
*/
}