I have built a system that conforms to the mvc pattern in PHP. The controllers and actions are part of the urls in my application. So I have:

So now I am looking for a way to pass on variables. For forms I just use the post method, but sometimes I would just like to link to a different page and then pass on some variables.

I would like some suggestions on how to do this. I know the Zend Framework has the variables as key/value pairs after the action in the controller using the "/" character as a separator, like this:

Is this the best way? This is actually the only way I know it's done. I am looking for an easy but yet good way to implement it.

Any suggestions are welcome.

4/13/2009 9:47:37 PM

Frameworks like CodeIgniter let you pass the variables into the controller without disclosing the variable name -


would get processed as:

function action( $id, $value){
  echo $id; // outputs 'foo'
  echo $value; // outputs 'bar'

I like this as it gives you control of how many parameters your controller will accept, and if it is important that certain variables are never used, you can do logic or redirect appropriately.

4/13/2009 9:36:47 PM

Licensed under: CC-BY-SA with attribution
Not affiliated with: Stack Overflow