Including other file in PHP for execution
In PHP there are two statements that will include functionality from other file. These keywords are include and require. Even so both of these statements will make code available for execution that is located in an another file, functionality of these two statements differ.
If a file that needs to be included is absent, than execution of code that follows include statement will be performed, however execution of the code will be aborted, if a file to which require keyword points to is absent.
Splitting functionality onto different files is useful in three cases:
1. Bringing functionality from another developer.
2. Making code more clearer to understand.
3. Avoid errors. If a code is included is known good code and a error arises, than error is probably is not within the code that is included.
Comments
Post a Comment