![]() |
Vad är skillnaden på funktionerna include_once() och require_once() i php?
|
om require_once inte hittar filen så avslutas php-skriptet. Om include_once inte hittar filen så fortsätter php-skriptet. Har jag för mig i alla fall.
|
Unlike include(), require() will always read in the target file, even if the line it's on never executes. If you want to conditionally include a file, use include(). The conditional statement won't affect the require(). However, if the line on which the require() occurs is not executed, neither will any of the code in the target file be executed.
|
Hur ofta använder man include_once() och require_once() istället för include() och require() tro? Har aldrig använt förstnämnda faktiskt.
|
Citat:
|
Citat:
t.ex databas inloggning... |
Citat:
|
Många om budet tycker jag :)
|
Citat:
Däremot kan man ju gott använda require eller include för header- eller footerdelar av sidan som mest innehåller html och kanske ska förekomma flera om gångar på sidan (require t ex för en header som måste vara med för att innehållet på sidan ska bli meningsfullt, include för någon spalt på sidan som inte absolut måste vara med – require ger resulterar ju annars i att sidan slutar ladda). |
Citat:
Citat:
|
Alla tider är GMT +2. Klockan är nu 19:31. |
Programvara från: vBulletin® Version 3.8.2
Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Svensk översättning av: Anders Pettersson