Welcome Guest, Not a member yet? Register   Sign In
pass variable to index
#1

[eluser]freshface[/eluser]
Hey

I want to pass a variable like this on the index function

index.php/controller/var
Code:
<?php

class Page extends Controller {

    function __construct()
    {
        parent::Controller();    
    }
    
    function index($p)
    {        
        echo $p;
    }

    
}

But that doesn't seems to be possible?
#2

[eluser]xwero[/eluser]
You have to set a default for $p otherwise you get errors when the method is accessed with the site.com/page url so your code would have to be changed to something like this
Code:
function index($p = FALSE)
    {        
        echo $p;
    }
    
    function tester($p = FALSE)
    {
        echo $p;
    }
#3

[eluser]freshface[/eluser]
I tested it and i always get

404 Page Not Found
The page you requested was not found.
#4

[eluser]xwero[/eluser]
If you don't use .htaccess mod_rewrite your url is site.com/index.php/page
#5

[eluser]gtech[/eluser]
.......index.php/controller/index/var

will work
#6

[eluser]xwero[/eluser]
*slaps forehead* Smile
#7

[eluser]freshface[/eluser]
me to Smile
#8

[eluser]gtech[/eluser]
hey I will slap mine too as I don't want to feel left out.
#9

[eluser]freshface[/eluser]
To get back on this, is there a way not to set the name 'index' of the controller.

Just controller/param (in the index function)

Could this be done wih routers? And how.


Thx in advance.




Theme © iAndrew 2016 - Forum software by © MyBB