Pomoc - Szukaj - Użytkownicy - Kalendarz
Pełna wersja: include a require
Forum PHP.pl > Forum > PHP
BzikOS
Jaka jest róznica między include, include_once, require, require_once?

Wiem tyle, że include to funkcja php, a require to kostrukcja językowa i że require nie zwraca wartości, ale prosiłbym o jakiś przykład praktycznego wykorzystania obu funkcji. Do czego stosować include, a do czego require (no i te _once).
maggot
The require() statement includes and evaluates the specific file.
dolacza i wykonuje podany plik

require() and include() are identical in every way except how they handle failure. include() produces a Warning while require() results in a Fatal Error.

czyli jesli bedzie blad przy include to wyrzuci blad i skrypt bedzie sie wykonywal dalej, jesli blad bedzie przy require to wyrzuci blad i zatrzyma skrypt

The include_once() statement includes and evaluates the specified file during the execution of the script. This is a behavior similar to the include() statement, with the only difference being that if the code from a file has already been included, it will not be included again. As the name suggests, it will be included just once.
BzikOS
Aaaaaha. I wszystko jasne.

Dzięki biggrin.gif
To jest wersja lo-fi głównej zawartości. Aby zobaczyć pełną wersję z większą zawartością, obrazkami i formatowaniem proszę kliknij tutaj.
Invision Power Board © 2001-2025 Invision Power Services, Inc.