Controller with Infinite Arguments($a,$b,$c,$d...), i.e. a Catch-all Solution |
[eluser]fireproofsocks[/eluser]
I know there are some libraries that do this, but I just needed this for a single controller... the situation is that a controller needed to handle some encypted data to validate an account. It worked fine until the encrypted data got forward slashes in it occasionally... and it was a variable number of them. Like a lot of hacks (e.g. to gain access to $_GET variables), this involves the $_SERVER variable. The goal was to have urls like: http://yoursite.com/x/y/1/2/3/4/5 and a controller that could have a single variable containing '1/2/3/4/5' Code: class X { This solution may not be 100% reliable, and it may not work on every server, so I suggest using it with caution.
[eluser]Michael Wales[/eluser]
I would just use URI Routing to catch everything and pass it as one variable to the method...
[eluser]danmontgomery[/eluser]
http://php.net/manual/en/function.func-get-args.php
[eluser]fireproofsocks[/eluser]
I tried using routing, both the normal routes and the regular expression routes, but I wasn't able to make this work e.g. Code: $route['x/y/(.*)'] = 'x/y/$1'; func_get_args() -- I didn't think of that... that function is not in my active vocabulary so it didn't leap to mind, but it's a simpler solution. |
Welcome Guest, Not a member yet? Register Sign In |