ابدأ بالتواصل مع الأشخاص وتبادل معارفك المهنية

أنشئ حسابًا أو سجّل الدخول للانضمام إلى مجتمعك المهني.

متابعة

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

user-image
تم إضافة السؤال من قبل مستخدم محذوف‎
تاريخ النشر: 2013/08/04
Hamzeh Abu Zakham
من قبل 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

Sandeep Mishra
من قبل Sandeep Mishra

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
من قبل 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();

المزيد من الأسئلة المماثلة