将带有短代码的文件渲染到wordpress插件中

I am relatively new to php and wordpress and I would like to know how I can render a php file without the include statement.

For example if I have two files plugin.php and component.php

plugin.php

<?php
  add-shortcode('myshortcode', 'myshortcode-func');

  function myshortcode-func()
    // magic function that loads
    $result = LOAD('component.php');
    return $result;
  }
?>

component.php

<div>
   <img scr="<?php getimage() ?>" />
</div>

NB I don't want to use include because I think it screws the rendering and insert the page in the flow when called.

Thanks for you help !

You can use an output buffer:

function myFunc(){
  ob_start();
  include('component.php');
  return ob_get_clean();
}

How to:

$php = file_get_contents("component.php");
eval($php);

eval is very dangerous though and shouldn't be used in production.

If this is for production, I'd recommend using hooks/filters (see wordpress source code). This lets you execute blocks of code on the fly, but is more constrained.