What happens if no file path is given in include() function?

Options
- PHP continues to execute the script.
- Results in a fatal error
- Include_path is made use of
- It haults the script.


CORRECT ANSWER : Include_path is made use of

Discussion Board
include() Function

This question has two possible answers, if a path is not provided then the script will use the include_path specified, and of course PHP will continue to execute the script even if the param of the include is empty. (That will throw warning but execution will continue)

Walter Pulido 09-27-2016 05:06 PM

The include statement includes and evaluates the specified file.

(PHP 4, PHP 5)
The include statement includes and evaluates the specified file.

The documentation below also applies to require.

Files are included based on the file path given or, if none is given, the include_path specified. If the file isn't found in the include_path, include will finally check in the calling script's own directory and the current working directory before failing. The include construct will emit a warning if it cannot find a file; this is different behavior from require, which will emit a fatal error.

If a path is defined — whether absolute (starting with a drive letter or \ on Windows, or / on Unix/Linux systems) or relative to the current directory (starting with . or ..) — the include_path will be ignored altogether. For example, if a filename begins with ../, the parser will look in the parent directory to find the requested file.

smzuber 08-19-2015 04:47 AM

include() Function

include() function takes a file name whose code you want to include in the current file, if that file does not exist then it will show us Warning and script will continue its execution....According to me correct if wrong...

S.M.ZUBAIR 10-10-2014 03:34 PM

Write your comments


Enter the code shown above:

(Note: If you cannot read the numbers in the above image, reload the page to generate a new one.)


Advertisement