testing
testing

Reputation: 20279

PHP include: How to include an external php file on a certain place in the html document

I have the following code

$content .= '
<div id="myDivID">';
    include 'search.php';
$content .= '
</div>';

But the included file is on top of the page. I want the output in between myDivID. Do I have an error in the php script or does the include always put it on top of the page?

Upvotes: 2

Views: 2816

Answers (2)

iThink
iThink

Reputation: 1259

<div id="myDivID">
    <?php require_once('search.php'); ?>
</div>

Upvotes: 2

genesis
genesis

Reputation: 50966

This one is correct

echo '<div id="myDivID">';
    include 'search.php';
echo '</div>';

Upvotes: 1

Related Questions