2 ms·
It's not terribly bad if you use it inside a function or method. Creating global variables is what causes all the issues, but then again, if you're handling glo
by kijin 12y ago
It's not terribly bad if you use it inside a function or method. Creating global variables is what causes all the issues, but then again, if you're handling global variables, you're asking for trouble anyway.
What's really bad about extract() is that the default behavior is to overwrite existing variables. This is just a recipe for disaster, no less than the infamous register_globals.
I once wrote a framework where the controller would pass variables to the view as $view->currentUser and the template would access it as $currentUser instead of the more verbose $this->currentUser. This was implemented with extract(), but I went to great lengths to make sure that the scope was clean.
PHP probably ain't gonna get rid of extract() any time soon, but at least they should change the default to EXTR_SKIP.