2013-03-02 93 views

回答

5

将其更改为:

<?php include_once 'example.php'; ?> 

如果您使用example.php包括类和其他代码,它分隔成一个文件的类,以及其他文件要执行多次的代码。然后在你要求上述代码的页面中,你可以这样写:

<?php include_once 'exampleClass.php'; ?> 
<?php include 'exampleCode.php'; ?> 
<?php include 'exampleCode.php'; ?> 
+0

谢谢,但是这只是运行example.php一次。我需要在相同的代码中运行example.php的多个实例。 – 2013-03-02 06:46:06

+2

您只能加入一次课程。你需要将example.php分成两个文件。一个包含您所包含并运行一次的类,另一个包含使用该类的代码的文件(您随后包含多次) – Jodes 2013-03-02 06:47:06

+0

谢谢您的澄清。这很好用! – 2013-03-02 07:26:29

相关问题