<p>Have a look at <a href="http://buildwithcraft.com/docs/plugins/variables">plugin template variables</a>. You can simply create a method in your plugins variable file that returns anything you want to the template, which would be accessible via <code>{{ craft.myplugin.customVariable }}</code>.</p>

<pre><code>&lt;?php
namespace Craft;

class MypluginVariable
{
    public function customVariable($someProperty = 'defaultValueIfNotDefined')
    {
        return 'Whatever you want!';
    };
}
</code></pre>

CC BY-SA 3.0
2014-11-09T07:24:36.757Z
2014-11-09T08:24:36.867Z
2014-11-09T08:24:36.867Z
Douglas McDonald
<p>For arguments sake let's say I wanted a plugin that is a basic output: </p>

<pre><code>&lt;?php echo '&lt;p&gt;Hello World&lt;/p&gt;'; ?&gt;
</code></pre>

<p>So all I am wanting to output is that, and I want that output to be available via twig (ie: {{ helloworld }}</p>

<p>Not passing any information, not doing anything with the craft database, etc. Just very basic. </p>

<plugin-development><plugins><php>
Is there a very very basic example of simply outputting PHP with a plugin to Twig?
# Is there a very very basic example of simply outputting PHP with a plugin to Twig?

(Asked by: username_0 on 2014-11-09)

For arguments sake let's say I wanted a plugin that is a basic output: 
Hello World'; ?>

So all I am wanting to output is that, and I want that output to be available via twig (ie: {{ helloworld }}
Not passing any information, not doing anything with the craft database, etc. Just very basic.

**Tags:** plugin-development, plugins, php

---

## 1 answers

### Answer by username_1 on 2014-11-09. Score: 8 | Accepted answer

Have a look at plugin template variables. You can simply create a method in your plugins variable file that returns anything you want to the template, which would be accessible via {{ craft.myplugin.customVariable }}.


---

