我尝试将HTML写入文件,一切正常但我无法根据用户输入插入字符串 - 你能告诉我这里我做错了什么吗?
<?php
if(isset($_POST['submit'])) {
$file = 'content.html';
$title = $_POST ['title'];
$content = '<li class="level-2"> <a class="level-2a" href="#">';
$content .= echo $title;
$content .= '
Lorem</a>
<div class="contentlevel2">
<span class="contentlilevel-2">
<!--ONEPAGECMS-START-';
$content .= echo $title;
$content .='
-->
Lorem Ipsum Doran....
<!--ONEPAGECMS-END-->
</span>
</div>
</li>';
file_put_contents($file, $content, FILE_APPEND | LOCK_EX);
}
?>
<div class="container">
<div class="col-sm-6">
<h1 class="text-center">Create new project</h1>
<form action="project.php" method="post">
<div class="form-group">
<label for="title">Project title</label>
<input type="text" name="title" class="form-control">
</div>
<input class="btn btn-primary" type="submit" name="submit" value="Create project">
</form>
</div>
答案 0 :(得分:0)
$content .= echo $title;
应该只是
$content .= $title;
你创建一个字符串,回显输出到&#39;屏幕&#39;
另外:$title = $_POST ['title'];
T和[之间没有空格(它会有点奇怪)