• 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Unable To call function from URL

[eluser]Blue Sapphire[/eluser]
I have following class code :


class Main extends Controller {

    function Main()
    function index()
        echo 'index Function';
    function myFunc()
        echo 'Another Function';


I have set route in routes.php as follows:
$route['admin'] = "admin/main";

I am using following url:

1- http://localhost/personal/com/admin/ [This works fine and shows message]

2- http://localhost/personal/com/admin/myFunc [This url gives me '404 Page Not Found' error].

Can some one guide me where I am wrong and in solving this problem.

Thanks in advance

[eluser]Blue Sapphire[/eluser]
Any solution?

When you set your routes, the first parameter is the controller, the second the method. So, in your example, you're trying to call the "main" method of the "admin" controller, which doesn't add up to what you have. If your application is admin, then setting the route to just "main" should do what you need.

[eluser]Blue Sapphire[/eluser]
Thanks for guidance. I have following scenario:

1- 'admin' is sub directory of 'controllers' directory. 'admin' directory will hold all admin related controllers.

2- 'main' is default controller in 'admin' sub directory. There will be many more controllers in 'admin' sub directory.

3- 'myFunc' is function in 'main' controller.

Your guidance will be higly appreciated in this scenario.

Thanks in advance

[eluser]Blue Sapphire[/eluser]
Any solution ?

Thanks in advance

try http://localhost/personal/com/admin/main/myFunc

Digg   Delicious   Reddit   Facebook   Twitter   StumbleUpon  

  Theme © 2014 iAndrew  
Powered By MyBB, © 2002-2020 MyBB Group.