我需要将路径作为参数传递给网址,例如 / Controller / Action / My-Path但My-Path包含正斜杠,例如/dir1/dir2/file.php 有没有办法将此路径作为单个参数传递,或者我需要将路径分解为/Controller/Action/Param1/dir1/Param2/dir2/Param3/file.php。一些示例代码将不胜感激
TIA Ephraim
答案 0 :(得分:4)
您可以使用网址视图助手,例如:
echo $this->view->url(
array(
'controller' => 'somecontroller',
'action' => 'someaction',
'path'=>'/dir1/dir2/file.php')
);
这将导致:
public/somecontroller/someaction/path/%2Fdir1%2Fdir2%2Ffile.php
url view helper自动使用url_encode对参数进行编码(参见其他anwser)。
答案 1 :(得分:0)