我需要在另一個函數裏面使用一個函數,我該怎麼做?我意識到函數超出了範圍,我不明白OOP和類。有人能幫我嗎?這裏如何在另一個函數中使用PHP函數?
function some_function ($dfd, $characters, $dssdf, $sdfds){
$sdfs = 'sdfsdf'; //random stuff goes on
//this is where my trouble begins I have a scope issue, I need to call this function inside of this function
readable_random_string($characters);
}
UPDATE是其他功能的要求
function readable_random_string($length = 6) {
$conso = array("b", "c", "d", "f", "g", "h", "j", "k", "l", "m", "n", "p", "r",
"s", "t", "v", "w", "x", "y", "z");
$vocal = array("a", "e", "i", "o", "u");
$password = "";
srand((double)microtime() * 1000000);
$max = $length/2;
for ($i = 1; $i <= $max; $i++) {
$password .= $conso[rand(0, 19)];
$password .= $vocal[rand(0, 4)];
}
return $password;
}
您可以顯示readable_random_string函數也是如此,所以我們可以看到範圍問題 – bumperbox 2009-09-07 03:38:36
絕對可以做到,它是大多數編程語言的基礎之一。你遇到的問題究竟是什麼? – Aziz 2009-09-07 03:38:58
@ bumperbox我添加了那部分 – JasonDavis 2009-09-07 03:44:31