Ben PHP çiftleşmiş önemini anlamaya başlıyorum. Ben herhangi bir yeni dil öğrenme önlemek için bir şablon motoru olarak PHP'nin kendisi kullanıyorum. Ben bu konuda bir fikrim var, ancak ben hala bir şey tho net değilim. Ben uzmanlar ne bilmek istiyorum.
Ben tüm tablolar, formlar ve (üstbilgi ve altbilgi dahil) her şeyi ile tam bir sayfa şablonu oluşturmanız gerekir, ya da ben kendi dosyasında vb benim tablolar, formlar, tüm koymak ve sonra gerektiği gibi şablonuna eklemek gerekir.
İşte şeyleri temizlemek için küçük bir örnek ...
Should I
a) içindeki tüm tablolar, formlar ve diğer unsurları ile bir sayfa oluşturmak ve bir nihai ürün olarak kullanan
// Set all the information
$template->title = $username;
$template->user_info = get_user($user_id);
$template->articles = get_articles($user_id);
$template->ads = random_ad($user_info);
// Load the template with everything already in it
$template->load('user_page.tpl')
$template->display();
VEYA
b) kendi dosyasında her tablo, form, ilgili blok elemanı oluşturmak ve sonra nihai bir ürün yaratmak için bunları kullanın
// set the title and load the header template
$header['title'] = $username;
$template->load('header.tpl', $header);
// get the user info as an array and load into user profile template
$user_info = get_user($user_id);
$template->load('user_profile.tpl');
// load the new article form
$template->load('new_article_form.tpl');
// get the articles as an array of info and load into user articles template
$articles = get_articles($user_id);
$template->load('user_articles.tpl', $articles);
// get a random ad based on user info
$ads = random_ad($user_info);
$template->load('advertisements.tpl');
// load the footer template and display final page
$template->load('footer.php');
$template->display();
Yüklenen her dosya nihai sayfada görüntülenecek gerekenleri küçük bir bölümünü içerir nerede.
Kendinizi tekniği tekrarlayın Dont çünkü, ben B düşünürdüm, ama bilmek istiyorum neden olan ve