Extension:Foxway

The Foxway extension allow you to embed blocks of PHP code into your pages and templates to be parsed and expanded by MediaWiki. It has its own implementation of the interpreter and runtime for PHP code. Therefore all PHP code is executed in a secure sandbox environment.

In the extension will be realized only functions that let process data and it will not be intended to run any programs on PHP.

...

Usage
The tag is used to embed blocks of PHP code into wikitext, which are then executed. The standard PHP functions  may be used to pass output back to the parser.

All variables declarations persist from one block/expression to the next, throughout the page. Complicated expressions and calculations can thus easily be separated from their presentation

See also other examples