Closed RZN-FFEvo closed 9 years ago
@RZN-FFEvo
What version of PHP are you using? I can't seem to replicate this issue. The correct number of parameters are being passed for me. Maybe a better question is in what instance is this occurring.
For instance, when I try it via a url like /home/exampleone/var1/var2
, both var1
and var2
are being successfully passed to my Home::exampleOne()
method. Is that the scenario where you're having the issue, or something else? (I'm new to mini, so I haven't fully explored all that it can do, therefore it's very possible it's a different scenario where the issue is occurring).
This is exactly what i am doing. I added a simple echo function to home.
public function say($what)
{
echo 'Say: Parameters: ' . print_r($what, true) . '<br>';
}
When called with http://test.MyDomain.com/home/say/var1/var2/
It prints:
App: Controller: home App: Action: say App: Parameters: Array ( [0] => var1 [1] => var2 ) Say: Parameters: var1
It should be noted that i am using nginx and it has been configured per the thread linked in the readme. PHP 5.4.41-0+deb7u1
I got around this issue by changing line 43 of application.php to:
$this->url_controller->{$this->url_action}($this->url_params);
I have yet to have any issues with this change.
Hey guys,
I think this is a.) an issue with wrong htaccess configuration (and you are using nginx, so this really might be the problem), or b.) an misunderstanding of how the params work, maybe I'm really talking stupid things right now, but I remember that 2 params work like public function say($what, $second, $third)
, but I'm unsure (sorry haven't worked on the project for a very long time). :)
Maybe this helps you...
You are correct, this is a misunderstanding of how params work.
say($var1, var2)..etc works perfectly
Thank you for your time.
@RZN-FFEvo
Shoot. I know you closed this issue. But in my earlier comment, I meant to say that /var1/var2
were successfully being passed to my Home::exampleOne($var1, $var2)
method. If I had been more specific in showing that I was actually adding $var1
and $var2
as arguments in my method, that probably would have cleared it up for you right there.
As an aside, even if you don't do exampleOne($var1, $var2, etc)
, you could still get any number of arguments via PHP's func_get_arg
and func_get_args
methods.
For example:
/**
* If you were to view /home/exampleone/var1/var2/var3,
* with your funtion setup like this:
*/
function exampleOne() {
/* You could still access var1, var2, var3, etc. with: */
$var1 = func_get_arg(0);
$var2 = func_get_arg(1);
$var3 = func_get_arg(2);
// Or, you could loop through a variable number of arguments:
$args = func_get_args();
foreach($args as $arg) {
echo $arg; // Would echo "var1" on the first iteration
}
}
btw FYI I'll add this to the docu/readme when there's time :)
application.php line 43 https://github.com/panique/mini/blob/master/application/core/application.php#L43
call_user_func_array(array($this->url_controller, $this->url_action), $this->url_params);
If $this->url_params is an array only the first element in the array is passed