ZF2 不允许我在字符串中制作锚标记

ZF2 is not letting me make anchor tag in a string

代码

 $responeHTml .= '<li class="col-xs-3"> <a href="'. $this->url("delete-export-rt", array("sid" => $sid, "row"=>$var->export_history[$i]["id"])).'> <i class="fa fa-trash-o"></i>
                        <div class="caption">Delete</div>
                        </a> 

错误

Catchable fatal error: Object of class Zend\Mvc\Controller\Plugin\Url could not be converted to string

您正在使用控制器助手,而不是您认为的视图助手。

通过在控制器中调用 $this->url();,您可以获得助手实例。然后你应该调用 fromRoute 方法来获取 url.

$this->url()->fromRoute("delete-export-rt", array("sid" => $sid, "row"=>$var->export_history[$i]["id"]))

This 是您尝试使用的插件。