最終的にフォームを作成すると思われる一連の関数があります。次の例のようなクラスに存在します。
class ExampleForm{
protected $_html = '';
protected $_element;
public function __construct($element){
$this->_element = $element;
protected function _open_form(){
echo $this->_html .= '<form>';
}
public function create_form(){
$this->_open_form()
$this->_html .= $this->_element;
echo "some content";
$this->_close_form()
}
protected function _close_form(){
echo $this->_html .= '</form>'
}
public function __toString(){
return $this->_html;
}
次のようにインスタンス化:
$element = 'some element';
new ExampleForm($element);
より包括的な例は、 Github の 86 行目で見ることができます 。
あなたがこれの実写デモを見たいなら、あなたは私を望まないでしょう. 一日の終わりに Web ページのフォームを調べると、フォーム開始タグの上に、フォーム タグ内にある必要がある 2 つの非表示フィールドが表示されます。
これにより、次のようなフォームが作成されると考えられます。
<form>
element
some conent
</form>
しかし、私が得たものは次のとおりです。
some content
<form>
element
</form>
上記の内容に基づいて、開始フォームタグをエコーしたにもかかわらず、「一部のコンテンツ」がフォームタグの外側にエコーされる理由を教えてもらえますか?
開始フォームタグをエコーしなくても、「一部のコンテンツ」が開始フォームタグの外側に表示されます。