在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