The typo3 extension "page_php_content" allows you to enter php -code as a part of a page and have it executed when building a page without writing an extension. If the code is more than a few lines it is advisable to write it in a file and just include it in the page content field.