Category Archives: Invision Power Board

Using PHP code in Invision Power Board templates

Invision Power Board gives you a PHP template tag. With this you can use PHP inside most templates (skin/block/page templates and more!).

Here’s a quick example of usage inside a template:

<php>
$foo = 5+5;
</php>

Print example 1 - {$foo}
Print example 2 - {parse expression="$foo"}

Both of the last two lines print our variable $foo. What’s interesting with the second example is that it can be used to evaluate a PHP expression.

For example, I had issues with an ISO-8859-1 RSS feed – to display it correctly, I ran it through utf8_decode(), as you can see in the example below:

{parse expression="utf8_decode($r['title'])"}

More reading
IPB Documentation on parse tags