Php – Zend_framework – relative paths of images

phprelative-pathzend-framework

When i am developing a web application on Zend_framework (php) i have to include images (css files, js files, etc).

The solution for inclusion was to specify the absolute paths each time i needed an image (i was storing in "global like" parameter with my host and concatenated it with the relative path of the image on the host). As i understand this solution is overpriced (for each picture to go the DNS service and so on) and i am looking for a simpler solution to the relative path problem.

P.S. The problem can be better described in the following example: when I am going to "http://myhost.com/" the images will be shown normally (the image path was: "./images/logo.jpg"). but it won't be seen from the "http://myhost.com/users/" url (to make it seen i had to change to image path to : "./../images/logo.jpg".

Id anybody knows how i can solve this problem, i will be glad to hear.

Gorelik.

Best Solution

You're looking for the BaseUrl helper.

<?php echo $this->baseUrl('images/logo.jpg'); ?>