Including other files in PHP

There are couple of keywords in PHP that will bring functionality from external files to the main code.

These keywords are include and require.

Difference between them is that by using keyword include the rest of the code of that program will continue to execute, if the file that is needed to included is absent.

require on other hand will fail the execution, if the file that is needed to be included is absent.

More than one file can be included for a program to operate.

It is a good practice to use include files, since it is possible to validate functionality of the code that is being included.

Including other code is beneficial since functionality of that code can be independently validated.

Comments

Popular posts from this blog

Absolute and relative path in HTML pages

Errors

goto PHP operator