KnowledgeHub
Questions
Tags
Users
Search
Alex Rivera
|
Logout
Edit Question
Title
Body
So, I don't come from a huge PHP background—and I was wondering if in well formed code, one should use the 'superglobals' directly, e.g. in the middle of some function say $_SESSION['x'] = 'y'; or if, like I'd normally do with variables, it's better to send them as arguments that can be used from there, e.g: class Doer { private $sess; public function __construct(&$sess) { $this->sess =& $sess; } } $doer = new Doer($_SESSION); and then use the Doer->sess version from within Doer and such. (The advantage of this method is that it makes clear that Doer uses $_SESSION.) What's the accepted PHP design approach for this problem?
Tags (comma-separated)
Save Edits
Cancel