PHP States

I received an email a couple days ago from a UScript developer who was interested in applying something that seems to be pretty useful in UScript to provide a similar interface in PHP5. States. UScript pt States provide a developer with a means of encapsulating code, much the same way many of us have been doing for a long time with switches, and define methods and change their desired functionality.

switch($var)
{
    case "quick":
        include "overview.php";
        break;
    case "full-view":
        include "full.php";
        break;
    default:
        include "frontpage.php"
        break;
}

This may not be the best example for switches and their functionality, I don’t even suggest you necessarily use this, but it shows one thing. Changing functionality, based on variables. I am looking into a solution that is not only useful, but is at least readable.

Leave a Reply