Is it possible to put _POST or _GET vars in a php 4+ class ??
if I had
I realize the above does not work, just wondering how to fix it.Code:class MyPost{ function MyPost(){ foreach ($_POST as $k => $v) $this->$k = $v; } }
Is it possible to put _POST or _GET vars in a php 4+ class ??
if I had
I realize the above does not work, just wondering how to fix it.Code:class MyPost{ function MyPost(){ foreach ($_POST as $k => $v) $this->$k = $v; } }
Solved it.
Code:class MyPost{ function MyPost(){ foreach ($_POST as $k => $v) $this->{$k} = $v; # reminder you can also use $_GET & $_COOKIE instead of $_POST } }
I see no real reason that wouldn't work. $_GET and $_POST are "autoglobals:" that is to say, they should be automatically defined in any function whose creation results from that request.
Twey | I understand English | 日本語が分かります | mi jimpe fi le jbobau | mi esperanton komprenas | je comprends français | entiendo español | tôi ít hiểu tiếng Việt | ich verstehe ein bisschen Deutsch | beware XHTML | common coding mistakes | tutorials | various stuff | argh PHP!
Bookmarks