Welcome Guest, Not a member yet? Register   Sign In
Objectify
#11

[eluser]Jamie Rumbelow[/eluser]
@GSV - No, each $object variable is in it's own vaiable scope inside the function so it wouldn't get erased.

And I've been using it to convert the $_POST array - it's just nice to have it as an object.
#12

[eluser]nmweb[/eluser]
Can you enlighten why you would want to do this? Syntactical sugar? Objects generally take up more memory and have no real added value in your testcase. Adding to that, maybe your php version is different but accessing $obj->0/$obj->1 etc. doesn't work (php5.2.6) Afaik as I know it doesn't work in any php version. So it won't work if your array has a numerical index. Having $_POST as an object is fine but objects have properties and methods for a reason. A valid reason could be to filter input ($_POST->get('email')(secure) vs $_POST->get_raw('email')(unfiltered) for example). Using php5's SPL you can even mimic the original array syntax so you can do $_POST=new Post($_POST): $_POST['email']; // secure, $_POST->raw('email');//unfiltered

This certainly has potential.




Theme © iAndrew 2016 - Forum software by © MyBB