Inserting html content from b.php into a div in the included a.php -
i have 2 files. a.php , b.php. a.php template including in b.php. here contents of a.php:
<div id="main"></div> here contents of b.php:
<?php include ('/a.php'); ?> <h1>hello</h1> how insert
<h1>hello</h1> into
<div id="main"></div> ?
the reason im asking because have login php file , have form in it. want insert template's main div section.
is possible or have copy template , paste login php file?
you handle giving template values should inserted placeholders in template. include inherits current scope of location include happens, example you'd
$content = "<h1>hello</h1>"; include("a.php"); .. , have echo($content) in a.php. i'd suggest using actual template library make more structured yourself.
since include inherits current scope, can wrap in function (or class , call method render template) avoid symbols leaking global scope. template engines in form (or rewrite accessors / variable names on parsing, if use specific syntax - i.e. smarty).
this particular case solved having header include contains <div ..> part, , footer contains </div> part, include / wrap around content.
Comments
Post a Comment