Re: PHP - open_basedir

From: Paco (paco@seznam.cz)
Date: 09. 10. 2002, 12:53 CEST


> Opravdu? A nezmenil si jeste k tomu require za include?
> Pokud jsem cetl dobre manual, tak kdyz funkce require nenajde soubor k
> vlozeni, ukonci se zpracovani celeho scriptu. Pokud pouzijes funkci
> include, ktera nenakezne vkladany soubor, vypise se warning a skript se
> zpracovava dal. Pokud u include potlacis ten vypis chyby pomoci @,
> skript bezi dal a hlaska se nevypise.

S tim ukoncenim mas pravdu, ale ten jeho require zrejme ten
soubor nalezl, kdyz ho vypsal. Alespon jsem tomu tak rozumel.

A jeste trosku ;-)) od veci:
Hlavni rozdil mezi require a include je predevsim v tom, ze
require CTE cilovy soubor VZDY, i kdyz neni explicitne volano.
Staci, ze se vyskytuje v kodu. Ignoruje tedy i podminku. To se
tyka ovsem jen CTENI ciloveho souboru jako takoveho. Pokud ale
radek s require nebude proveden, nebude proveden ani ten kod
z ciloveho souboru. Take ignoruje cykly, etc., takze jej nelze
pouzit pro vkladani ruznych souboru v cyklu. Provede se pouze
jednou, ale pozor, prvne nacteny kod uz zustava soucasti cyklu!
Lze tak snadno vyrobit zacykleni a obtizne potom hledat jeho
priciny. Nejasnosti v rozdilech require vs. include jsou velice
castymi stesky useru. V manualu je ale vsechno velice podrobne
a srozumitelne popsano. Kdyby useri RTFM, meli by pak podstatne
mene starosti... ;-)). Tady je aspon zkraceny vynatek:

pako Paco. 

----------------

require() is not actually a function in PHP; rather, it is a language 
construct. It is subject to some different rules than functions are. For 
instance, require() is not subject to any containing control structures. 
For another, it does not return any value; attempting to read a return 
value from a require() call results in a parse error.
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. 
Similarly, looping structures do not affect the behaviour of require(). 
Although the code contained in the target file is still subject to the 
loop, the require() itself happens only once. 
This means that you can't put a require() statement inside of a loop 
structure and expect it to include the contents of a different file on 
each iteration. To do that, use an include() statement.
In PHP 3, it is possible to execute a return statement inside a require()ed
file, as long as that statement occurs in the global scope of the
require()ed file. It may not occur within any block (meaning inside braces
({}). In PHP 4, however, this ability has been discontinued. If you need
this functionality, use include(). 


______________________________________________________________________
Reklama:
Jake bude pocasi? http://pocasi.seznam.cz



This archive was generated by hypermail 2.1.2 : 09. 10. 2002, 13:01 CEST