! ! 0 Junior Poster Banned

http://www.justatheory.com/bricolage/1.9.0.html


And finally—yes, you heard right—Bricolage now supports PHP 5 templating in addition to the existing Perl-based templating architectures (Mason, Template Toolkit, and HTML::Template). So how did we add PHP 5 templating to a mod_perl application? Easy: we hired George Schlossnagle of Omni TI to write PHP::Interpreter, an embedded PHP 5 interpreter. Now anyone can natively execute PHP 5 code from a Perl application. Not only that, but the PHP 5 code can reach back into the Perl interpreter to use Perl modules and objects! Here’s an example that I like to show off to the PHP crowd:

<?php
$perl = Perl::getInstance();
$perl->eval("use DBI");
$perl->eval("use DateTime");
$dbh = $perl->call("DBI::connect", "DBI", "dbi:SQLite:dbname=dbfile");
$dbh->do("CREATE TABLE foo (bar TEXT, time DATETIME)");
$now = $perl->call("DateTime::now", "DateTime");
$ins = $dbh->prepare("INSERT INTO foo VALUES (?, ?)");
$ins->execute("This is a test", $now);
$sel = $dbh->prepare("SELECT bar, time FROM foo");
$sel->execute();
$a = array("foo", "bar");
foreach ($sel->fetch() as $val) {
	 echo "$val\n";
}
$sel->finish();
$dbh->do("DROP TABLE foo");
$dbh->disconnect();
?>
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.