2011-05-31 82 views
0

我在我的页面中显示地图,使用静态PHP,因为所有关于地图的代码都是map.php如何将map.php作为img标签的源代码

在Symfony中,我很困惑在何处放置我的map.php文件以及如何将该文件包含为img标记的源。

回答

2

你可以用它来完成它。动作:

public function executeShowmap(){ 
    $this->getResponse()->setHttpHeader('Content-type', 'image/jpeg'); 
    $this->getResponse()->setContent(file_get_contents($filename)); 
    return sfView::NONE; 
} 

,并在视图:

img src="<?php echo url_for('module/showmap'); ?>" 
+0

在哪里得到的文件名穿过? ;-) – Flukey 2011-05-31 07:43:26

+0

@jamie,这只是一个例子......猜他在map.php中获得了更多的逻辑。只是通过一个动作传递图片将是...愚蠢的。 ;) – Flask 2011-05-31 08:18:56