title: Getting basepath from view in zend framework
body: <p>Case: you're developing a site with Zend Framework and need relative links to the folder the webapp is deployed in. I.e. <code>mysite.com/folder</code> online and <code>localhost:8080</code> under development.</p>
  
  <p>The following works nice in controllers regardless of deployed location:  </p>
  
  <pre><code>$this-&gt;_helper-&gt;redirector-&gt;gotoSimple($action, $controller, $module, $params);
  </code></pre>
  
  <p>And the following inside a viewscript, ie. index.phtml:  </p>
  
  <pre><code>&lt;a href="&lt;?php echo $this-&gt;url(array('controller'=&gt;'index', 'action' =&gt; 'index'), null, true); ?&gt;"&gt;
  </code></pre>
  
  <p>But how do I get the correct basepath when linking to images or stylesheets? (in a layout.phtml file, for example):  </p>
  
  <pre><code>&lt;img src='&lt;?php echo WHAT_TO_TYPE_HERE; ?&gt;images/logo.png' /&gt;
  </code></pre>
  
  <p>and  </p>
  
  <pre><code>$this-&gt;headLink()-&gt;appendStylesheet( WHAT_TO_TYPE_HERE . 'css/default.css');
  </code></pre>
  
  <p><code>WHAT_TO_TYPE_HERE</code> should be replaced with something that gives </p>
  
  <pre><code>&lt;img src="/folder/images/logo.png /&gt;` on mysite.com and `&lt;img src="/images/logo.png /&gt;
  </code></pre>
  
  <p>on localhost</p>