cilveks Posted October 6, 2006 Report Share Posted October 6, 2006 Es tikai saaku maaciities php peec shiis pamaaciibas http://webtech.lv/php_reference/ un man nestraadaa viens piemeers, raada erroru - Parse error: parse error, unexpected T_STATIC, expecting '{' in .. on line 4 <?php function hitcount( ) static $count = 0; if ($count == 0) { echo "This is the first access to this page"; } else { echo "This page has been accessed $count times"; } $count++; } ?> ja es pirms vaarda static pielieku { iekavu, tad vispaar tuksha lapa paraadaas. Man aizdoma ka kaut kas nav ar php konfiguraaciju kaartiibaa. Kur ir mana kljuuda? Piemeers ir kopeets no mineetaas lapas, nekas nav paarveidots. Link to comment Share on other sites More sharing options...
bubu Posted October 6, 2006 Report Share Posted October 6, 2006 Funkcijas atverošā figūriekava nav uzlikta. Jābūt ir: function hitcount() { <----- šitā te tev nebija ... } Nevajag uzticēties visam, kas kautkur rakstīts. Vajag saprast, kas tur tiek demonstrēts un ja redzi kļūdiņu, tad pielabo to. A tukša lapa ir tāpēc, ka tu nekā neizvadi. Uzraksti: echo "Hello world!"; un tad redzēsi, kas parādīsies. Un btw teksts tajā funkcijā neatbilst pateisībai. Funkcija neizvadīs to cik reizes tu esi apskatījies lapu, bet gan to cik reizes funkcija tiek izsaukta skripta darbības laikā. Link to comment Share on other sites More sharing options...
cilveks Posted October 7, 2006 Author Report Share Posted October 7, 2006 Ok, tik daudz saprotu ka tas nav lapas skaitiitaajs, jo dati netiek netur saglabaati. Bet kaapeec vinjsh neizvada vismaz sho visu laiku - "This is the first access to this page"? Link to comment Share on other sites More sharing options...
Klez Posted October 7, 2006 Report Share Posted October 7, 2006 tas tapee ka $count vislaik ir nulle. Link to comment Share on other sites More sharing options...
cilveks Posted October 7, 2006 Author Report Share Posted October 7, 2006 Nu jaa, bet tas arii neizpildaas, uz ekraana netiek izvadiits nekas. Tuksha balta lapa. Vajadzeetu buut, ja count=0 tad echo "This is the first access to this page"; Link to comment Share on other sites More sharing options...
Blitz Posted October 7, 2006 Report Share Posted October 7, 2006 lai kautkas paraditos to funkciju vajag ari izsaukt. Ieraksti kautkur hitcount(); Link to comment Share on other sites More sharing options...
v3rb0 Posted October 7, 2006 Report Share Posted October 7, 2006 statiskais variablis $count 0 būs tik pirmo reizi viņu 'aiztiekot'. function cnt() { static $count = 0; echo $count++ .'<br />'; } for ($i=0; $i<=10; $i++) cnt(); Link to comment Share on other sites More sharing options...
Recommended Posts