Skip navigation.
Home

PHP

Lazy Evalutation in PHP (sorta)

This is a nice little example that will show you how to do something really useful and cool. It'll also show you how PHP kinda sucks:

<?php

function f( $x )
{
say("function f called with $x...");
return create_function( '', " return quote('$x'); ");
}

function quote( $s )
{
say('quote called...');
return '***'.$s.'***';
}

say('starting...');

$x = f( 'hello, world' );

say('$x defined as '.$x.'...');

print $x();

///// utility funcs
function say( $s ) { echo $s.'<p>'; }

The results look like this:

starting...

function f called with hello, world...

$x defined as �lambda_6...

quote called...

***hello, world***

j_oocms - an excessively object-oriented cms

They say it's bad to use extend too much. This is a *bad* cms.

It's a simple image gallery, suitable for things like personal image hosting.

This was written to study how extend works, and to try out some ideas. At this time, there are six (6) classes. These include text data, html data, form data, multimedia, and photos.

One feature is that there's no relational database. The data fields are defined by the data that's POSTed to the server. This is probably a security hole, but, the idea was to see how it would "feel" to hack in such an environment. It was pretty cool.

Another feature is support for attached multimedia. At this time, that's only photos and html files. Still, it's something.

No Eval? Variable Interpolation on PHP Code

We recently turned off the websites' ability to use the eval() or related functions. In a small CMS I'd written a while back, I was using eval to interpolate variable names in strings. This was a simple way to do "lazy evaluation" on strings I was using as templates. With eval, there was no need to use a special templating syntax - the syntax was PHP's.

Now, with eval turned off, I needed a function to interpolate variables in a string. Here it is:

function interpolate( $string )
{
foreach ($GLOBALS as $name => $value)
{
$string = str_replace( '$'.$name, $value, $string );
}
$string = preg_replace( '/[$]\\w+/', '', $string );
return $string;
}

TXTMOB for Web Hosts (project)

This is a hack of txtmob that's being developed to run on cheap web hosts.

So far, it'll let you send to the group via the web form, so it's suitable for a one-way, moderated list. Good for news.

The sms forwarding feature doesn't work, so, it's not able to do "real" txtmob yet. Maybe it will one day... This code is very alpha, and based on code from SourceForge, that was at version 0.14, so you know what you're getting :-)

I'm not forking the project. This is just a personal fork for personal use.

Fun Details, and Some Roadmapping

Syndicate content