Start networking and exchanging professional insights

Register now or log in to join your professional community.

Follow

Can we use include ("xyz.PHP") two times in a PHP page "index.PHP"?

user-image
Question added by Deleted user
Date Posted: 2013/08/04
Hamzeh Abu Zakham
by Hamzeh Abu Zakham , Director of Software Development , bayt.com

You can include the same php script more than once by using include directive, output from the example below confirm this: a.php <?php echo "Test \n"; b.php <?php include("a.php"); include("a.php"); calling b.php prints the following: Test Test

Yes, we can use include("xyz.php") two times but, this is not a good practice. If you have defined any class or function in that file then it will be redefined and PHP throws an error.

Mohamed El Shaer
by Mohamed El Shaer , Senior System Engineer , Etisalat UAE

yea you can include the file as many as you want since you are using include() or require(); if you want to include the file ONLY once ,, you can use include_once(); or require_once();

More Questions Like This