dotjay.com / lab / tests / php / vcard

vCards with PHP and htaccess

Last updated: May 8, 2007

These tests use spoof vCards, so please don’t try to use them for contacting anyone.

Normal vCard tests

A normal vCard with .vcf file extension (no content-type header)

Does not get parsed as a vCard by some browsers (e.g. Firefox).

Same vCard file with .vcf file extension and htaccess forcing the correct text/x-vcard content-type

If you don’t have access to your php.ini file, this is most useful. Uses the following code in an htaccess file:

<Files ~ "\.vcf$">
	ForceType text/x-vcard
</Files>

PHP vCard tests

These tests use a line of PHP to send the correct text/x-vcard content-type:

<?php header('Content-Type: text/x-vcard; charset=utf-8'); ?>

A vCard in PHP with .php file extension

Gets parsed as PHP but doesn’t have the correct file extension. Not ideal.

Same vCard in PHP but with .vcf file extension

Oops! This will not be parsed as PHP!

Same vCard in PHP with .vcf file extension and htaccess forcing application/x-httpd-php

A very round–about way of doing things!