Hallo,
ich möchte mir eine Klasse für ein Anmeldeformular erstellen habe aber Probleme mit der heredoc Syntax.
PHP-Code:
<?php
class anmeldeform{
private $action;
private $form= <<<Überschrift
<h1>hier loggen Sie sich ein </h1>
also bitte<br>
hier:
<table>
<form action="$this->action" method="post">
<tr>
<td>Benutzername</td>
<td><input type="text" name="benuztername"></input></td>
</tr>
<tr>
<td>Passwort</td>
<td><input type="password" name="passwort"></input></td>
</tr>
<tr>
<td><input type="submit" value="abschicken"></input> </td>
</tr>
</table>
</form>
Überschrift;
function __construct($zieldatei){
$this->action=$zieldatei;
}
function formularErstellen(){
echo $this->form;
}
}
?>
Der Fehlercode:
Code:
Parse error: syntax error, unexpected T_VARIABLE, expecting T_END_HEREDOC in /home/cabanni/public_html/worksp/Kursangebot/AnmeldeForm.php on line 11
Linie 11 ist diese Zeile:
Code:
<form action="$this->action" method="post">
Wäre euch sehr dankbar wenn ihr mich zu der Lösung meines Fehlers führt ;)
Interessant und eigentlich so geplant, wäre es auch so:
Code:
private static $action="$_SERVER['PHP_SELF'];
dann müsste Zeile 11 wohl so aussehen:
Code:
<form action="self::$action" method="post">
Leider ist über Heredoc wenig zu finden, zumindest wenn es über die Verwendung einer simplen Variable hinaus geht.
Gruß