多次包含php文件


include php file many times

我想在另一个文件中包含一个.php文件。但我想做很多次。对于每一个,我都会传递具体的参数。我想在加载时打印结果页。

例如,想象我有一个像这样的html:

<html>
    <body>
        <div id="#friend1">
            Name: <input/>
            Age: <input />
        </div>
        <div id="#friend2">
            Name: <input/>
            Age: <input />
        </div>
        <button>print</button>
    </body>
</html>

我有另一个文件,它在一个很酷的wai中打印朋友信息,比如:

<html>
    <body>
        <div>
            Yo are my friend<?php echo $_SESSION['friend']?> you are <?php echo $_SESSION['age']?>              
        </div>
    </body>
</html>

我想将此文件包含具体信息以便打印。我一直在尝试包含o要求,但没有成功。只显示了其中一个。参数传递正确,我不知道如何使它。

有什么想法吗?非常感谢!

我会尽量更具体一点:

<?php
    session_start();
?>  
<!DOCTYPE html
    PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="es" lang="es">
<meta charset="utf-8">
<head>
</head>
<script type="text/javascript">
    <?php 
        require_once ("jqdirectPrint.js");
    ?>
</script>
<body onload="printLoad();">
     <?php 
         for ($i = 0; $i < sizeof($_SESSION['friendList']); $i++) {
              $_SESSION['friend']=$_SESSION['friendList'][$i];
              require 'friendInfo.php';
         }
     ?>
</body>
</html>

friendInfor.php只是一个html表单,它显示了具体朋友的信息。但只显示了第一个。我想为清单上的每个元素显示相同的表格。它只包含标签。

Hobo Sapiens是对的,我在friendInfo.php上有一些额外的标签,所以我删除了它们,效果很好。所以,谢谢你的帮助。require允许您多次引入或加载同一文件。

仍在等待一些不错的PHP手册的检查。)