I am looking into building my own custom small framework and trying to make it as flexible as possible, I have now got to the input process of the design and I am wondering how I could implement the "request" class and how to return POST params from a POST request, etc.
I noticed that a lot of frameworks have a request class which hook directly into the "php://input" stream which I have tried to do and would like to utilize, however the only problem is this returns a string instead of an object or array of value=params.
What may be the best way for me to implement a method which would give me access to the param values of a POST request? I could probably explode the "php://input" string however this would be messy, I also tried the parse_str() on the stream which worked however sadly this also has issues if one of those values is something along the lines of foo">bar< as it seems to break out of the object and leave me with a partial incomplete value of foo.
My ultimate solution would be something along the lines of:
$_POST contains foo=bar;arg=value;
class request {
function get($arg=null)(){
if(!arg){/* return all, both foo and arg accessible*/}
else
/*return single value of the param with the $arg text*/
}
$foo = request->get('foo'); // "bar"
$all = request->get() // foo=bar;arg=value;
print $all->arg; // "value"