Thursday, August 27, 2009

Doc Comment could be a source of data!!!

While discussing ways of using PHP as data storage file, we passed over this interesting possibility.

PHP data file: CommentDataClass.php
Doc Comment could be a SOURCE OF DATA
This could be your data in string format!!
class CommentDataClass { }

Retrieving data: Data.php
include_once 'CommentDataClass.php';

// Taking advantage of PHP 5.x Reflection,
// Refer:

$reflectedClass = new ReflectionClass('CommentDataClass');

$reflectedClass->getDocComment(), $matches)) {
$data = $matches[1];
$data = trim($data);

var_dump(explode("\n", $data));
Well, this is just for fun, we don't recommend it for serious use :)

This page is powered by Blogger. Isn't yours?