謝謝你的時間。修改現有的腳本以接受不同的參數
我想修改現有的PhP腳本來接受第23行的用戶輸入字符串。現在它只接受放入數組的數字。
<?php
function isJewishLeapYear($year) {
if ($year % 19 == 0 || $year % 19 == 3 || $year % 19 == 6 ||
$year % 19 == 8 || $year % 19 == 11 || $year % 19 == 14 ||
$year % 19 == 17)
return true;
else
return false;
}
function getJewishMonthName($jewishMonth, $jewishYear) {
$jewishMonthNamesLeap = array("Tishri", "Heshvan", "Kislev", "Tevet",
"Shevat", "Adar I", "Adar II", "Nisan",
"Iyar", "Sivan", "Tammuz", "Av", "Elul");
$jewishMonthNamesNonLeap = array("Tishri", "Heshvan", "Kislev", "Tevet",
"Shevat", "", "Adar", "Nisan",
"Iyar", "Sivan", "Tammuz", "Av", "Elul");
if (isJewishLeapYear($jewishYear))
return $jewishMonthNamesLeap[$jewishMonth-1];
else
return $jewishMonthNamesNonLeap[$jewishMonth-1];
}
$jdNumber = gregoriantojd(12, 12, 2016);
$jewishDate = jdtojewish($jdNumber);
list($jewishMonth, $jewishDay, $jewishYear) = explode('/', $jewishDate);
$jewishMonthName = getJewishMonthName($jewishMonth, $jewishYear);
echo "<p>The Jewish date of death is $jewishDay $jewishMonthName $jewishYear</p>\n";
?>
我想是該行
$jdNumber = gregoriantojd(12, 12, 2016);
接受,而不是具體的數字,用戶輸入。我在想,你可以使用$ userinput,但是拋出了預期的3個字符串的錯誤,得到了一個。
再次,這不是我的特長,但我作爲項目的後端被投入混合。我不希望代碼爲我寫,只是朝着正確的方向推動。謝謝。