PHP Classes

A PHP Framework in 140 Characters

Recommend this page to a friend!
  Blog PHP Classes blog   RSS 1.0 feed RSS 2.0 feed   Blog A PHP Framework in 14...   Post a comment Post a comment   See comments See comments (2)   Trackbacks (0)  

Author:

Updated on: 2021-07-16

Posted on: 2021-07-16

Viewers: 1,084 (July 2021)

Categories: PHP Tutorials

Many developers create their frameworks. Usually, they are complex because they implement many features.

If we had the challenge to make a framework that is so small that it would fit in a 140 characters Twitter message, it could not do much, but it is possible to be done.

Read this article to learn how to overcome the challenge of making a small but useful framework in just 140 characters.




Loaded Article

The 140 Characters PHP Code Version

This is a very small framework for PHP inspired by the framework of Fabien.

Please ignore security limitations for not considering that GET parameters may contain malicious values that could be used to access any file in the server machine on which PHP is running.

$c=$_GET['c'];$a=$_GET['a'];if(@include_once('c/'.$c.'.php')){$c=new$c;if(method_exists($c,$a))$c->$a();else die("A !f");}else die("C !f");

The Well Formatted PHP Code Version

<?php

$c = $_GET['c'];                    //controller name 
$a = $_GET['a'];                    //action name
if (@include_once('c/'.$c.'.php'))
{
    $c = new $c;                    //controller instance
    if (method_exists($c,$a))       
        $c->$a();                   //invoking the action
    else
        die("A !f");                //controller not found
}
else die("C !f");                   //action not found

?>
Greetings!!!



You need to be a registered user or login to post a comment

Login Immediately with your account on:

FacebookGmail
HotmailStackOverflow
GitHubYahoo


Comments:

1. http://www.twitto.org/ has an 404 error - van Gato (2021-07-16 16:23)
Take a look at the google cache... - 1 reply
Read the whole comment and replies



  Blog PHP Classes blog   RSS 1.0 feed RSS 2.0 feed   Blog A PHP Framework in 14...   Post a comment Post a comment   See comments See comments (2)   Trackbacks (0)  
For more information send a message to info at phpclasses dot org.