View Single Post
Old 07-17-2005, 01:36 AM   #6 (permalink)
redhead
Newbie
 
redhead's Avatar
 
Join Date: Jun 2002
Location: Denmark
Posts: 1,693
redhead is on a distinguished road
I'm guessing the issue here is from, what I can remember, bad coding style learned during the VB/BASIC days, where you would say, "Hey I need to dynamicaly use some variable.. Well lets just create what we want:, ie:
PHP Code:
$my_hey "this is hey";
$my_yo "this is yo";
function 
give_me($decide){
    return ${
"my_$decide"};

Which could easily be changed to:
PHP Code:
$myArray = array(
         
"hey" => "this is hey",
         
"Yo"  => "this is Yo");
function 
give_me($decide){
    return 
$myArray[$decide];

For whatever reason I frequently see old BASIC programmers using loops with referencing variables like that, where they just append the current index to teh variable name, instead of just looping through an array..

For readability, and maintainability, I would rather have it in an array where the code is kinda self explaining, instead of some giberish someone would have to rewrite 5 years from now, because it's just poor programming style.
__________________
Don't worry Ma'am, We're university students, We know what We're doing.
-----
If you pull the pin, Mr.Grenade would no longer be your friend.
-----
01000111 01101111 00100000 01000011 00100000 00100001
redhead is offline   Reply With Quote