2013-04-16 60 views
-1

我有一个自己正确工作的PHP文件,但我需要它在我的主页的某个部分上运行,名为file.php。如何在PHP中运行PHP文件?

我希望myfile.php在file.php里面运行,我正确地将容器分配给我需要它的地方,并尝试了<?php include("myfile.php"); ?>它的工作原理,但我想要它的自动大小。

假设myfile.php有宽度大小为900px的表格,但是当我在myfile.php中打开file.php和表格大小时会变为渐变。大小变成900px以下。如何使仍然900px的表里面myfile.php其中运行里面file.php与div容器?

+1

完全糊涂了 –

+1

你说的...“包括”? ...'iframe'? ...'div' style'overlay'? – Voitcus

+0

@Welly:'<'符号被解释为标记的一部分。您可能想要在反引号之间转义它们或您的代码行。您问题的其他部分不可见。 – Hennes

回答

0

在file.php

include "path/to/myfile.php";

1

可以用PHP“包括”

<div id="container"> 
<?php include("myfile.php"); ?> 
</div> 

顺便说一句,你想用的尺寸做什么,我相信你会需要CSS要做到这一点,而不是PHP。

也许这样

myfile.php

<table style="width:900px"> 
<tr><td></td></tr> 
</table> 
+0

仍然不起作用。 –

+0

你可以在这里粘贴你的代码吗? –

+0

仍然无法正常工作。任何想法? –

0

此代码index3.php与格

<!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"> 
<head> 
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /> 
<title>JS Change Class</title> 
<script language="JavaScript" src="js/adspreview.js"type="text/javascript" xml:space="preserve"></script> 

<div id="container"> 
     <td><?php include("test.php"); ?> 
</div> 
</html> 

这里的代码,我想index3.php内运行

<html> 

<head> 
<meta http-equiv="Content-Language" content="en-us"> 
<meta http-equiv="Content-Type" content="text/html; charset=windows-1252"> 
<title>Test</title> 
</head> 

<body> 

<table border="1" width="100%"> 
    <tr> 
     <td bgcolor="#0000FF" colspan="2"> 
     <p align="center"><font color="#FFFFFF" face="Arial"><b>Test</b></font></td> 
    </tr> 
    <tr> 
     <td>&nbsp;</td> 
     <td>&nbsp;</td> 
    </tr> 
</table> 

</body> 

</html> 

Ple这是一个尝试,我对此感到困惑。感谢您的帮助。

0

第一: index3.php

<!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"> 
<head> 
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /> 
<title>JS Change Class</title> 
<script language="JavaScript" src="js/adspreview.js"type="text/javascript" xml:space="preserve"></script> 
</head> 
<body> 
<div id="container"> 
     <?php include("test.php"); ?> 
</div> 
</body> 
</html> 

二: teste.php

<table border="1" width="100%"> 
    <tr> 
    <td bgcolor="#0000FF" colspan="2"> 
     <p align="center"><font color="#FFFFFF" face="Arial"><b>Test</b></font> 
    </td> 
    </tr> 
    <tr> 
     <td>&nbsp;</td> 
    </tr> 
</table> 

CTRL + C + CTRL + V ^^