sample code for Google Client API published

Gallery

The sample code for the Google Client API pages has been updated. It now uses the names of the new Google Client PHP API release and also switched from object – reference to arrays. Finally the source code is available … Continue reading

phpMicroformats – PHP class library for microformats

About phpMicroformats

phpMicroformats is a PHP class library that helps to generate valid microformats for e.g. calendar events (hCalendar) or vcards (hCard). It is released under GPL license.

About Microformats

Microformats are specific enriched html structures that both helps humans and computers to understand the content. There are formats for calendar events called hCalendar – based on vCalendar format – and vcards – based on vCard format – and more.
The advantage of using microformats is that it is easier for humans to understand but also for computers to interpret and understand. Since it is using wildly accepted standards as (x)html enriched with some specific but limited classes, it can be easily implemented.

Advantages

  • Based on wildly accedpted standards as xhtml
  • Defines specific formats for limitd domains as e.g. calendar data or vcards
  • Helps to classifiy and structure data for both humans and computers
  • Will help computers to better understand the content of websites
  • Can be integrated and used easily with full backward compatibility.

Disadvantages

  • Maybe a bit more work to encode the data in the required formats.
  • Up to now only a few formats are set up for limited domains.
  • Not officially used by search engines spiders up to now.

Requirements for phpMicroformats

There are no special requirements besides PHP.

Usage of phpMicroformats

  1. Download phpMicroformats and copy the class phpMicroformats.class.php to your webserver.
  2. Experiment with the microformat examples available: Generate your first hCalendar or hCard entry.

Download

phpMicroformats Release 0.1 (supports hCalendar and hCard; ZIP-compressed)

Examples for generation of microformat entries

Sample code for encoding of a vcard

<?php
/*
* example php script that generates and outputs a hcard entry
*/

$myPersonalData = array(
‘name’ => ‘Steve F. Better’,
’email’ => ‘abuse-me@this-host-is-not-existing.info’,
‘org’ => array(
‘name’ => ‘The virtual company’,
‘title’ => ‘General chief of all’
),

‘location’ => array (
‘street’ => ‘Main street 15b’,
‘town’ => ‘Mainhattan’,
‘zip’ => ‘22912’,
‘state’ => ‘Main country’,
‘country’ => ‘Countrinidad’
),

‘phone’ => array(
‘home’ => ‘+1 123 66 71 292’,
‘cell’ => ‘+1 123 88 72 121’
),

‘photo’ => ‘http://non-existing-domain.com/no-image-available.jpg’,

‘im’ => array(
‘skype’ => ‘echo-chinese’,
‘aim’ => ‘ShoppingBuddy’
)
);
require_once(
‘phpMicroformats.class.php’);
echo
phpMicroformats::createHCard($myPersonalData);
?>

Sample code for encoding of a calendar event

<?php
/*
* example php script that generates and outputs a hcalendar entry
*/

$myEvent = array(
‘name’ => ‘Release party of phpMicroformats’,
‘begin’ => time(),
‘end’ => time()+2*60*60, // duration: 2 hours

‘location’ => array (
‘street’ => ‘Main street 15b’,
‘town’ => ‘Mainhattan’,
‘zip’ => ‘22912’,
‘state’ => ‘Main country’,
‘country’ => ‘Countrinidad’
),
‘url’ => ‘http://enarion.net/phpmicroformats/’
);

require_once(‘phpMicroformats.class.php’);
echo
phpMicroformats::createHCalendar($myEvent);
?>

JpGraph – a free php diagram library

Imagine, you have some data that you would like to visualize. But normally this is a really ugly job.
JpGraph is a really easy to use php library that helps you dealing with such problems.

diagram example code

<?php
require_once("jpgraph.php");
require_once("jpgraph_line.php");
$prod=array(12,14,3,8,12,'',7,13,19.5,4);
$graph = new Graph(540,300);
$graph->SetScale('intlin');
$lineplot1=new LinePlot($prod);
$lineplot1->SetFillColor("orange");
$graph->Add($lineplot1);
$graph->Stroke();
?>

results in the following diagram:

JpGraph example for a line plot, generated with PHP

JpGraph example for a line plot, generated with PHP

More information about JpGraph

You can find more information about JpGraph on the homepage of JpGraph. It’s free for non-commercial use; for commercial usage, the author charges little money – compared to other available (commercial) tools.