2013-04-16 61 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 ^^