4

I need to pass a path as a parameter to a url e.g. /Controller/Action/My-Path but My-Path contains forward slash e.g. /dir1/dir2/file.php Is there any way of passing this path as a single parameter or do I need to break the path down as /Controller/Action/Param1/dir1/Param2/dir2/Param3/file.php. Some sample code would be appreciated

TIA Ephraim

overthink
  • 23,360
  • 3
  • 65
  • 69
Ephraim
  • 199
  • 1
  • 2
  • 18

2 Answers2

4

You can use url view helper, e.g.:

    echo $this->view->url(
            array(
            'controller' => 'somecontroller',   
            'action' => 'someaction',    
            'path'=>'/dir1/dir2/file.php')
            );

This will result in:

public/somecontroller/someaction/path/%2Fdir1%2Fdir2%2Ffile.php

url view helper automatically uses url_encode to encode your parameters (see other anwser).

Marcin
  • 168,023
  • 10
  • 140
  • 197
0

See: http://ar2.php.net/url_encode

so you would do:

$param = url_encode("/this/parameter/file");
marcelog
  • 6,842
  • 1
  • 32
  • 46