Answers.Body: <p><strong>Solution:</strong></p>
  
  <pre><code>return craft()-&gt;config-&gt;get('environmentVariables')['baseUrl'];
  </code></pre>
  
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2015-06-18T14:34:32.983Z
Answers.Text: For older versions of PHP:
  var enVar = craft()->config->get('environmentVariables'); return enVar['baseUrl'];
Answers.UserDisplayName: Mark Notton
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2015-06-18T14:20:12.610Z
Answers.LastActivityDate: 2015-06-18T14:20:12.610Z
Answers.UserDisplayName: Mark Notton
Body: <p>A <a href="https://craftcms.stackexchange.com/questions/3089/grab-environmentvariables-with-a-tag">similar question was answered before</a>, but I was wonder how I might be able to return the same query from within a plugin (php)?</p>
  
  <p><strong>Convert this:</strong></p>
  
  <pre><code>{{ craft.config.environmentVariables.baseUrl }}
  </code></pre>
  
  <p><strong>To something like this</strong>: <em>(not correct)</em></p>
  
  <pre><code>return craft()-&gt;config-&gt;get('environmentVariables.baseUrl');
  </code></pre>
  
  <p>What would be the correct syntax?</p>
  
  <p>Thanks, Mark.</p>
  
Tags: <config><variable><environmentvariables>
Title: Getting environmental variable via plugin
ThreadText: # Getting environmental variable via plugin
  
  (Asked by: username_0 on 2015-06-18)
  
  A [similar question was answered before](https://craftcms.stackexchange.com/questions/3089/grab-environmentvariables-with-a-tag), but I was wonder how I might be able to return the same query from within a plugin (php)?
  
  **Convert this:**
  
  ```
  {{ craft.config.environmentVariables.baseUrl }}
  
  ```
  
  **To something like this**: *(not correct)*
  
  ```
  return craft()->config->get('environmentVariables.baseUrl');
  
  ```
  
  What would be the correct syntax?
  
  Thanks, Mark.
  
  **Tags:** config, variable, environmentvariables
  
  
  ---
  
  ## 1 answers
  
  ### Answer by username_0 on 2015-06-18. Score: 11 | Accepted answer
  
  **Solution:**
  
  ```
  return craft()->config->get('environmentVariables')['baseUrl'];
  
  ```
  
  > **Comments:**
  > **username_0**: For older versions of PHP: var enVar = craft()->config->get('environmentVariables'); return enVar['baseUrl'];  
  
  ---
  
  