why we require include and require ?
1.when we have to use same lines of code again and again then we use include and require;
for example->code for connection to a database ,we required very freqeuntly so why to insert
some 7-8 to line of code many times in script.
so to save us include and require comes into the picture.
How include and require work
step 1->>>write the code which you need in a seperate php file;
for example->for connecting to database,we have writen in db_connect.php
step 2--->now wherever you need database connection simply write
require 'db_connect.php';
or
include 'db_connect.php';
difference between include and require
suppose the file which you wrote in include and require is not present .
lets say you write
require 'db_connect1.php';
include 'db_connect1.php';
but db_connect1.php file is not there then in that case
---->include will not show you the error but----->>>>require will show.
No comments:
Post a Comment