![]() |
| ||
| Bricolage - PHP5 & Mod Perl 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]<?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(); ?> [/PHP] |
| All times are GMT -4. The time now is 11:44 pm. |
Forum system based on vBulletin Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
©2003 - 2008 DaniWeb® LLC