Answers.Body: <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>
  
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2014-11-09T07:24:36.757Z
Answers.LastActivityDate: 2014-11-09T08:24:36.867Z
Answers.LastEditDate: 2014-11-09T08:24:36.867Z
Answers.UserDisplayName: Douglas McDonald
Body: <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>
  
Tags: <plugin-development><plugins><php>
Title: Is there a very very basic example of simply outputting PHP with a plugin to Twig?
ThreadText: # 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:
  
  ```
  <?php echo '<p>Hello World</p>'; ?>
  
  ```
  
  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](http://buildwithcraft.com/docs/plugins/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 }}`.
  
  ```
  <?php
  namespace Craft;
  
  class MypluginVariable
  {
      public function customVariable($someProperty = 'defaultValueIfNotDefined')
      {
          return 'Whatever you want!';
      };
  }
  
  ```
  
  
  ---
  
  