How to use PHP code with wordpress page

The best way to create dynamic data outputs really depends on the what, why, and how.

For example, if you’re creating a theme that creates its own custom post type, say, to store information about the head honchos that run the business behind the site, then just create a “single-$CPTNAME.php” template that has the code that you want.

Another method of doing this would be to create a custom template, and simply select that for a given page. See the WordPress Page Templates documentation for more information on how to create the custom templates and make them selectable in the WordPress admin UI.