我正在开发一个项目,我通过php创建一个页面,但创建的页面是空白的,我的意思是没有HTML,但我需要做的是在该页面中也有html
这是我正在创建页面
的帮助下的代码 $ourFileName = $title.".php";
$ourFileHandle = fopen($ourFileName, 'w') or die("can't open file");
fclose($ourFileHandle);
但是当页面创建我希望这个html也在那个页面中
<div class="content">
<form action="" class="valid" method="post" enctype="multipart/form-data">
<div class="row">
<label>Title</label>
<div class="right"><input type="text" name="title" value="<?php echo $row['title'];?>"
/></div>
</div>
<div class="row">
<label>Link</label>
<div class="right"><input type="text" name="link" value="http://localhost/admin/your page name"
/></div>
</div>
<div class="row">
<label></label>
<div class="right">
<button type="submit"><span>Enter menu item</span></button>
<input type="hidden" name="hidden" />
</div>
</div>
</form>
</div>
答案 0 :(得分:3)
如果你的意思是想要结合php和html ,你可以将你的php包装到html网站中,例如:
<html>
<title>...</title>
<?php
echo 'this comes from php';
?>
<p>Some HTML Text</p>
<?php
echo '<b>You could also add some html tags here</b>';
?>
</html>
确保将其保存为.php
,以便由php进程执行。
如果您想从php 创建html文件,您必须使用以下内容:
<?php
file_put_contents('somefile.html', '<html>...</html>');
?>
答案 1 :(得分:0)
如果我正确理解了这个问题,您正在使用:
$ourFileName = $title.".php";
$ourFileHandle = fopen($ourFileName, 'w') or die("can't open file");
fclose($ourFileHandle);
添加包含页面中显示的代码的文件。
那不行。除了你打开和关闭文件而不对它做任何事情之外,你所包含的文件/ html包含php。
如果你想要执行该文件中的php,你需要包含该文件而不是打开和编写它:
$ourFileName = $title.".php";
include $ourFileName;
答案 2 :(得分:0)