Communiquez avec les autres et partagez vos connaissances professionnelles

Inscrivez-vous ou connectez-vous pour rejoindre votre communauté professionnelle.

Suivre

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

user-image
Question ajoutée par Utilisateur supprimé
Date de publication: 2013/08/04
Hamzeh Abu Zakham
par 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
par 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