PHP -
JAVA -
HTML
Now create as many pages as you want and insert this file to create the header. For example, test.php may have the following content.
The example illustrates how to include files in PHP!
Save the above program in a file named test.php in htdocs , then open the browser and type the address http:/// localhost: 8080 / test.php will result:
The function require () takes all the text in the specified file and copies them into the file using the require function. If there is any problem during file loading, the require () function generates a fatal error (Fatal Error) and prevents the execution of the script.
So there is no difference between require () and include () besides they handle error conditions. We encourage you to use require () function instead of include (), because the script should not continue executing if the file is missing or the name is wrong.
You can use the above example with the require () function and it will generate the same result. But if you try to follow the following two examples, and if with a file does not exist, you will get different results.
The example illustrates how to include files in PHP!
Save the program in a file named test.php in htdocs , then open the browser and type in the address http:/// localhost: 8080 / test.php will result (done on Google Chrome):
Now try the above example with the require () function in PHP.
The example illustrates how to include files in PHP!
The executable file this time pauses and does not display anything.
Save the program in a file named test.php in htdocs , then open the browser and type in the address http:/// localhost: 8080 / test.php will give the result (I do it on Google Chrome):
Note - You may receive a warning message or error message or nothing. This depends on your PHP Server configuration.
Follow tutorialspoint
Previous lesson: String (String) in PHP
Next lesson: File & I / O in PHP