0

MVC の Heredoc は、レイヤーの分離への進出を開始する良い方法ですか? 使用できる場所と、ヒアドキュメントが解決するよりも多くの問題を抱えている場所を読みました。

4

2 に答える 2

3

いいえ。HEREDOCは MVC とはまったく関係ありません。HEREDOC は、文字列を区切る方法の 1 つにすぎません。これは、層を区切るのに一重引用符と二重引用符のどちらが適しているかを尋ねるのと同じです。

MVC のアイデアは、ユーザー インターフェイスを 3 つの別々の役割に分割することです。他の MVC の質問で数分前にこれに答えたので、リンクします。MVC に関する SO については、他にも多くの優れた質問があります。検索機能を使用するだけです。

于 2010-09-24T21:47:16.790 に答える
1

Heredoc is a method of sorts, but, no it is not a good way. Especially if you are doing this inside of the controller. You should separate your "view" logic into different files then you would just include the view you need depending on the controller / action.

Doing it as an include you can easily use <?php echo $variable; ?> and do your view logic in that file. You might also consider using a prebuilt framework, such as Zend or Codeigniter, among others which take the MVC approach.

于 2010-09-24T21:35:01.310 に答える