PHP - 使用include,我可以在页面中的不同div上执行吗?

I have a small problem, and I'll try to break it down into a smaller one so I can explain it properly.

I'm working on a web application and I have a couple of divs, such as this:

<div class="1">
//search bar
</div>

<div class="2">
include_once 'actioncontroller.php';
</div>

<div class="3">

</div>

In the actioncontroller.php I'm having an action controller which decides what action to take depending on what's pressed on the page. I've put it in the second div because ultimately that's where I want to print everything.

My question is, is there any way that I can use the code from the second div in the first one, without it printing it there? Basically I want the search bar from div one to do/print the same thing as the one in div 2 does, but I know(think) that PHP can't see code above the include_once, and if I include the actioncontroller.php in the first div it will print it there, instead of printing it in the second one, as I want.

Hope I was clear enough, it's not a problem of coding, it's just a matter of how can I read the script in the first div and then run it in the second one...

Thanks in advance

This code takes the output of actioncontroller.php and saves it into a variable, which can be echo'd multiple times.

<?php
ob_start();
include_once 'actioncontroller.php';
$output = ob_get_contents();
ob_end_clean();
?>

<div class="1">
    <?php echo $output; ?>
</div>

<div class="2">
    <?php echo $output; ?>
</div>

My question is, is there any way that I can use the code from the second div in the first one, without it printing it there?

Yes, but the best solution is to change the code you've already written. In the long-term, it is vitally important that you minimize your "procedural" PHP code, so that nothing ever happens simply by include/require-ing a file.

Trust me on this, it works for toy project, but it always leads to insanity and pain in the end. For example, don't put this in a file:

<?php    
echo("Header section");

This is bad because you have no choice about when it prints. This is a step up:

<?php
function WriteHeader(){
    echo("Header section");
}    

Even better would be to use classes an autoloading, but that's probably more than you need to hear right now. With that kind of approach, your main page would look more like:

<?php
// This next line simply makes the class ActionController *available*, 
// it does NOT cause new things to happen on its own
include_once("actioncontroller.php");

?>
<div class="1">
    <?= ActionController::MakeSomeHTML(); ?>
</div>

<div class="2">
    <?= ActionController::MakeSomeHTML(); ?>
</div>

<div class="3">

</div>