Welcome Guest, Not a member yet? Register   Sign In
Class with name "api" won't work as library or model
#1

[eluser]Unknown[/eluser]
I'm wondering if using "api" as a classname is not working because it's a reserved class name or if codeigniter is blocking the name. My code:
Code:
<?php if (!defined('BASEPATH')) exit('No direct script access allowed');

class api  extends CI_Model
{
    function get() {
     return TRUE;
    }
}
?>
I have tried it as a library and a model and both have failed. I know it must be the name of the class because I can change it to "papi" and it works.
#2

[eluser]InsiteFX[/eluser]
First character has to be upper case Api
#3

[eluser]Unknown[/eluser]
Thanks for the quick reply but that isn't the reason. It worked with "papi" as lower case and all my other classes work with lower case names.
#4

[eluser]InsiteFX[/eluser]
Well I has a class named Api and it works fine!

Library class by CodeIgniter should have the first character upper case even in the filename!

Naming Conventions
File names must be capitalized. For example: Myclass.php
Class declarations must be capitalized. For example: class Myclass
Class names and file names must match.

Also you cannot have two classes with the same name!




Theme © iAndrew 2016 - Forum software by © MyBB