With register globals you don't have any control over what you port in, that why register globals a bad thing. With this type of method you can set conditions and determine what happens, in the case above moving a database record to variables (add extra filtering as needed) saves a ton of code and to me looks easy to understand.John Cartwright wrote:Reminds me of register globals. Why do we hate arrays so much!?JoeCommodore wrote:Here is my example:
This is the type of stuff I use it for the most - reading in db fields into variables:Same goes for initializing and reading in filtered POST data into variables (from a an array of POST variable names I specify)Code: Select all
$things = mysql_fetch_assoc($result); foreach($things as $key => $value) { $$key = $value; }
Arrays are OK, but in my mind using it for everything adds a layer to working with the data, and could affect overall performance. I do love arrays, and use them a lot, as arrays.