PHP意外的“

时间:2019-12-16 15:17:57

标签: php html

您好,我正在为一个学校项目工作,我们必须编写一份手册。为此,我和我的队友正在研究网站手册。但是我们不想为每一章都写所有的html标签,所以我试图使html的记录器总是将1章写到主文件中。

当前代码如下:

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <meta name="author" content="Cédric Volk | Dodoe Mannale | Patrick Bühler">
    <meta name="publisher" content="Cédric Volk">
    <meta name="copyright" content="Cédric Volk">
    <meta name="description" content="Anleitung für SQL Injections im Rahmen vom Modul M214 LB2">
    <meta name="page-topic" content="Bildung">
    <meta name="page-type" content="Anleitung">
    <meta http-equiv="content-language" content="de">
    <meta name="robots" content="index, follow">

    <script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.4.1/jquery.min.js" integrity="sha256-CSXorXvZcTkaix6Yvo6HppcZGetbYMGWSFlBw8HfCJo=" crossorigin="anonymous"></script>
    <script src="../js/sidenav.js"></script>
    <script src="https://cdnjs.cloudflare.com/ajax/libs/materialize/1.0.0/js/materialize.min.js" integrity="sha256-U/cHDMTIHCeMcvehBv1xQ052bPSbJtbuiw4QA9cTKz0=" crossorigin="anonymous"></script>
    <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/materialize/1.0.0/css/materialize.min.css">
    <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/skeleton/2.0.4/skeleton.css">
    <link rel="stylesheet" href="../css/style.css">
    <link rel="shortcut icon" href="../img/docicon.ico" type="image/x-icon">
    <title>Documentator</title>
</head>
<body>
    <?php include "formular.php"?>
    <?php include "controller.php"?>
</body>
</html>

其中Formular.php如下:

<h1>The Holy Documentator</h1>
<form action="controller.php" method="GET">
        <div class="row">
            <div>
                <div class="col s1">
                    <label>
                        <input value="2" name="changeH" type="radio" />
                        <span>H2</span>
                    </label>
                </div>
                <div class="col s1">
                    <label>
                        <input value="3" name="changeH" type="radio" />
                        <span>H3</span>
                    </label>
                </div>
                <div class="col s1">
                    <label>
                        <input value="4" name="changeH" type="radio" />
                        <span>H4</span>
                    </label>
                </div>
                <div class="col s1">
                    <label>
                        <input value="5" name="changeH" type="radio" />
                        <span>H5</span>
                    </label>
                </div>
                <div class="col s1">
                    <label>
                        <input value="6" name="changeH" type="radio" />
                        <span>H6</span>
                    </label>
                </div>
            </div>
            <div class="col s1" id="GENChapNum">
                <input type="number" name="number" placeholder="KapitelNr.">
            </div>
            <div class="col s1" id="GENTitel">
                <input type="text" name="title" placeholder="Überschrift">
            </div>
            <div class="col s1" id="GENTask">
                <input type="text" name="task" placeholder="Aufgaben Tag">
            </div>
        </div>
        <div class="row">
            <div class="GENChap input-field col s12">
                <textarea class="materialize-textarea" name="chapter" placeholder="Kapitelinhalt"></textarea>
                <label for="chapter">Kapitelinhalt</label>
            </div>
        </div>
        <div id="submit">
            <button class="btn" type="submit" name="action" value="create">Erstellen</button>
        </div>
    </form>

和controller.php像这样:

<?php
if(@$_GET['action'] == 'create'){
    if(@$_GET['changeH'] && @$_GET['number'] && @$_GET['title'] && @$_GET['task'] && @$_GET['chapter']){
        $path = "../html/main.html";
        $myChap = "<div class='chap" . $_GET['number'] . "'>
                    <h" . $_GET['changeH'] . ">" . $_GET['number'] . " " . $_GET['title'] . "<h$_GET['changeH']>\
                    <p>\
                    " . $_GET['chapter'] . "
                    </p>
                    <a class='waves-effect waves-light btn modal-trigger' href='#modal" . $_GET['number'] . "'>Beispiel</a>
                   </div>";

        file_put_contents($path, $myChap, FILE_APPEND);
    }
}
?>

我收到的错误是: PHP语法检查:语法分析错误:语法错误,意外的''(T_ENCAPSED_AND_WHITESPACE),在第6行的代码中期望'-'或标识符(T_STRING)或变量(T_VARIABLE)或数字(T_NUM_STRING)

我也在互联网上搜索过它,但并没有真正找到有用的东西。

感谢您的帮助:D

0 个答案:

没有答案