在php文件中有多個包含

[英]Have multiple includes in a php file


I am trying to call 2 functions that i have in 2 separate .php files. Let's say that function1() is in my_functions1.php and function2() is in my_functions2.php.

我試圖在2個單獨的.php文件中調用2個函數。假設function1()在my_functions1.php中,而function2()在my_functions2.php中。

lets say i have in the same folder a third file called main.php and i want to include the functions from both my_functions1.php and my_functions2.php.

假設我在同一個文件夾中有一個名為main.php的第三個文件,我想要包含my_functions1.php和my_functions2.php中的函數。

Something like this

像這樣的東西

<?php
include 'my_functions1.php';
include 'my_functions2.php';

function1();
function2();

?>

For some reason i can't have 2 include files. I am kind of new in PHP and it seems that there is nothing on google about this except of putting all the functions in one file.

由於某種原因,我不能有2個包含文件。我是PHP的新手,似乎除了將所有函數放在一個文件中之外,Google上沒有任何內容。

1 个解决方案

#1


1  

Try using include_once. You might be accidentally including the same file multiple times.

嘗試使用include_once。您可能會多次意外包含同一文件。


注意!

本站翻译的文章,版权归属于本站,未经许可禁止转摘,转摘请注明本文地址:https://www.itdaan.com/blog/2014/03/30/190580bcb7c3de11b4f2d4bfa8015edb.html



 
粤ICP备14056181号  © 2014-2021 ITdaan.com