本文整理匯總了PHP中Component::serialize方法的典型用法代碼示例。如果您正苦於以下問題:PHP Component::serialize方法的具體用法?PHP Component::serialize怎麽用?PHP Component::serialize使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類Component
的用法示例。
在下文中一共展示了Component::serialize方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: testStuff
function testStuff()
{
$vcard = new Component('VCARD');
$vcard->VERSION = '3.0';
$vcard->PHOTO = base64_encode('random_stuff');
$vcard->PHOTO->add('BASE64', null);
$vcard->UID = 'foo-bar';
$result = $vcard->serialize();
$expected = array("BEGIN:VCARD", "VERSION:3.0", "PHOTO;BASE64:" . base64_encode('random_stuff'), "UID:foo-bar", "END:VCARD", "");
$this->assertEquals(implode("\r\n", $expected), $result);
}
示例2: testAnotherSerializeOrderProp
function testAnotherSerializeOrderProp()
{
$prop4s = array('1', '2', '3', '4', '5', '6', '7', '8', '9', '10');
$comp = new Component('VCARD');
$comp->__set('SOMEPROP', 'FOO');
$comp->__set('ANOTHERPROP', 'FOO');
$comp->__set('THIRDPROP', 'FOO');
foreach ($prop4s as $prop4) {
$comp->add('PROP4', 'FOO ' . $prop4);
}
$comp->__set('PROPNUMBERFIVE', 'FOO');
$comp->__set('PROPNUMBERSIX', 'FOO');
$comp->__set('PROPNUMBERSEVEN', 'FOO');
$comp->__set('PROPNUMBEREIGHT', 'FOO');
$comp->__set('PROPNUMBERNINE', 'FOO');
$comp->__set('PROPNUMBERTEN', 'FOO');
$comp->__set('VERSION', '2.0');
$comp->__set('UID', 'FOO');
$str = $comp->serialize();
$this->assertEquals("BEGIN:VCARD\r\nVERSION:2.0\r\nSOMEPROP:FOO\r\nANOTHERPROP:FOO\r\nTHIRDPROP:FOO\r\nPROP4:FOO 1\r\nPROP4:FOO 2\r\nPROP4:FOO 3\r\nPROP4:FOO 4\r\nPROP4:FOO 5\r\nPROP4:FOO 6\r\nPROP4:FOO 7\r\nPROP4:FOO 8\r\nPROP4:FOO 9\r\nPROP4:FOO 10\r\nPROPNUMBERFIVE:FOO\r\nPROPNUMBERSIX:FOO\r\nPROPNUMBERSEVEN:FOO\r\nPROPNUMBEREIGHT:FOO\r\nPROPNUMBERNINE:FOO\r\nPROPNUMBERTEN:FOO\r\nUID:FOO\r\nEND:VCARD\r\n", $str);
}