Welcome Guest, Not a member yet? Register   Sign In
Is Controller Index are not recommended?
#1

[eluser]rahendz[/eluser]
I create controller like structure below :

Code:
controller
- app
-- index.php

and inside index.php i put controller class like below :

Code:
<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
class Index extends CI_Controller {
public function index()
{
  echo "Here i am";
}
}
/* End of file index.php */
/* Location: ./application/controllers/zudan/index.php */

and i accessed using this url like below :

Code:
http://localhost/index.php/app/index

and it show that echoing twice like below :

Code:
Here i amHere i am

so what i'm gonna ask is Controller Class with Index as a Name of Class not recommended since it called twice? or i got something wrong? thanks before and sorry for my bad english.
#2

[eluser]Narf[/eluser]
That's a PHP limitation, or more specifically a BC feature for the PHP4 days. Having a method name that matches the class name makes it a constructor.
#3

[eluser]rahendz[/eluser]
[quote author="Narf" date="1407245413"]That's a PHP limitation, or more specifically a BC feature for the PHP4 days. Having a method name that matches the class name makes it a constructor.[/quote]

Ahh, i see. So that's why it called twice. thanks Narf.
#4

[eluser]Tpojka[/eluser]
[quote author="rahendz" date="1407254122"][quote author="Narf" date="1407245413"]That's a PHP limitation, or more specifically a BC feature for the PHP4 days. Having a method name that matches the class name makes it a constructor.[/quote]thanks Narf.[/quote]

+1




Theme © iAndrew 2016 - Forum software by © MyBB