kajusMedlem sedan sep. 2000221 inlägg Varför funkar inte detta:
<?php
function getQuote($day) {
$quote[1] = "text";
$quote[2] = "text";
$quote[3] = "text";
$quote[4] = "text";
$quote[5] = "text";
$quote[6] = "text";
$quote[7] = "text";
$quote[8] = "text";
$quote[9] = "text";
$quote[10] = "text";
$quote[11] = "text";
$quote[12] = "text";
$quote[13] = "text";
$quote[14] = "text";
$quote[15] = "text";
$quote[16] = "text";
$quote[17] = "text";
$quote[18] = "text";
$quote[19] = "text";
$quote[20] = "text";
$quote[21] = "text";
$quote[22] = "text";
$quote[23] = "text";
$quote[24] = "text";
$quote[25] = "text";
$quote[26] = "text";
$quote[27] = "text";
$quote[28] = "text";
$quote[29] = "text";
$quote[30] = "text";
$quote[31] = "text";
return "$quote[$day]";
}
function dailyQuote() {
$day = date("j");
echo getQuote($day);
}
?>
------------------
...
return "$quote[$day]";
ändra till
return $quote[$day];
------------------------
function dailyQuote() {
$day = date("j"); //ändra
echo getQuote($day);
}
ändra till
function dailyQuote() {
$dag = date("j"); //ändra
echo getQuote($dag);
}
Nu kanske det funkar ??
?>
------------------
//ToBBe §jr
kajusMedlem sedan sep. 2000221 inlägg Det funkar fortfarande inte...
------------------
...
Ehhhh, jo. Ditt script skall fungera, du måste ju anropa funktionen dailyQuote() för att få något resultat men det antar jag att du gör?
Som vanligt så är det superlattjolajbans med felmeddelanden och annan nödvändig information för att kunna hjälpa till.
Dela med dig av dessa och du skola se ljuset och höra änglarnas skönsång.
------------------
"Med ett schysst järnrör slår man hela världen med häpnad" - Socker-Conny
nanneMedlem sedan dec. 19991 749 inlägg Prova med att bygga din array på detta sättet istället och se om det fungerar då
$quote = Array(
[0] => "text"
[1] => "text"
[2] => "text"
[3] => "text"
[4] => "text"
[8] => "text"
[9] => "text"
);
------------------
-----BEGIN GEEK CODE BLOCK-----
Version: 3.1 decoce
GCM/MU/IT$>AT d--- s: a-- C++$ UL P-- L++>++++ E W+++>$ N o-- K- w O- !M V?
PS++ PE- Y+ PGP-@ t+ 5 X+++ R* tv- b++ DI D++ G+ e* h++ r++ y+**@
------END GEEK CODE BLOCK------
kajusMedlem sedan sep. 2000221 inlägg Hur ska jag anropa funktionen då?
------------------
...
nanneMedlem sedan dec. 19991 749 inlägg dailyQuote();
------------------
-----BEGIN GEEK CODE BLOCK-----
Version: 3.1 decoce
GCM/MU/IT$>AT d--- s: a-- C++$ UL P-- L++>++++ E W+++>$ N o-- K- w O- !M V?
PS++ PE- Y+ PGP-@ t+ 5 X+++ R* tv- b++ DI D++ G+ e* h++ r++ y+**@
------END GEEK CODE BLOCK------
Som jag skrev ovan så funkar din kod utmärkt men du måste ju anropa den, annars får du liksom inget resultat, någonsin...
------------------
"Med ett schysst järnrör slår man hela världen med häpnad" - Socker-Conny
Ställ dig på ett berg och anropa funktionen genom att ropa i en näverlur.
Eller så skriver du <? dailyQuote(); ?> någonstans i HTML-koden där du vill ha utdatat från funktionen.
------------------
"Med ett schysst järnrör slår man hela världen med häpnad" - Socker-Conny