PHP, bu gibi bazı kod var ki:
$infrastructure = mt_rand(0,100);
if ($infrastructure < $min_infrastructure) $infrastructure = $min_infrastructure;
//do some other stuff with $infrastructure
$country->set_infrastructure($infrastructure);
$education = mt_rand(0,100);
if ($education < $min_education) $education = $min_education;
//do some other stuff with $education
$country->set_education($education);
$healthcare = mt_rand(0,100);
if ($healthcare < $min_healthcare) $healthcare = $min_healthcare;
//do some other stuff with $healthcare
$country->set_healthcare($healthcare);
Gibi denebilecek bir işlevi içine talimatlar bu benzer setleri birleştirerek bazı yolu var mı:
change_stats("infrastructure");
change_stats("education");
change_stats("healthcare");
Temel olarak, can you use variables in PHP in other variable names and function names?
Şimdiden teşekkürler.