Hi all, Very basic question from a PHP amateur... When doing a php include of stuff you want in a DIV, is it more correct to call the include from inside the div tags, or to put the div tags inside the included content? Thanks in advance,
depends what your doing. if the div is part of your page structure then this would make more sense to me: <div id="content"><?php include('content.php')?></div> Then you can control your site structure from your style sheet But there is nothing wrong in having markup in your includes either eg: content.php may contain: <div class="title"><?php echo 'my title is '.$title?><?div>
Ah, yes. Thank you. The DIV would be to apply CSS styling, so I guess: <div id="content"><?php include('content.php')?></div> would be the appropriate solution. Have a great night!
With Includes, PHP grabs that file, places the script in its place. So it does not matter if the div is in the include or not. Includes are good, for example links. If you add a new page or delete a page, instead of changing every page with the updates links, just use one file. The only problem with including a div in the include, it that if you want to add something at the bottom of the include, but in the same div, you can't easily.
yes With an include you type in the code <?php echo "hello"; include "file.php"; ?> and on file you have echo "yes"; Your script will go up and look like this <?php echo "hello"; echo "yes"; ?> and it will print helloyes (no breaks)
Yes, it makes no difference if your divs are inside your includes or not. But it does make sense to have your page structure (read template) outside of your includes: eg <div id="content"><? include('content'.php)?></div> or <div id="content"> <php if ($case==true) { include('content'.php); } else { include('somethingelse'.php) } ?> </div>