<p><strong>Solution:</strong></p>

<pre><code>return craft()-&gt;config-&gt;get('environmentVariables')['baseUrl'];
</code></pre>

CC BY-SA 3.0
2015-06-18T14:34:32.983Z
For older versions of PHP:
var enVar = craft()->config->get('environmentVariables'); return enVar['baseUrl'];
Mark Notton
CC BY-SA 3.0
2015-06-18T14:20:12.610Z
2015-06-18T14:20:12.610Z
Mark Notton
<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>

<config><variable><environmentvariables>
Getting environmental variable via plugin
# Getting environmental variable via plugin

(Asked by: username_0 on 2015-06-18)

A similar question was answered before, 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'];  

---

