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, and never use direct run custom code in PHP interpreter installed on your computer
 * This extension does not allows run php code! It works the same way as other extensions like Extension:ParserFunctions, but instead of using wiki syntax, uses the syntax of PHP.
 * This extension does not allow creation of raw HTML pages, because MediaWiki parser processes the foxway outputs like any other text

You can try it in sandbox.

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