Welcome Guest, Not a member yet? Register   Sign In
is loading through static class is bad idea?
#15

If you really want to save some typing create a helper.

/application/helpers/load_helper.php
PHP Code:
<?php
if(!function_exists('view'))
{

 
   function view($view$data null$return FALSE)
 
   {
 
       $obj = & get_instance();
 
       return $obj->load->view($view$data$return);
 
   }

}

if(!
function_exists('library'))
{

 
   function library($lib$config null$obj_name null)
 
   {
 
       $obj = & get_instance();
 
       return $obj->load->library($lib$config$obj_name);
 
   }

}

if(!
function_exists('model'))
{

 
   function model($model)
 
   {
 
       $obj = & get_instance();
 
       return $obj->load->model($model);
 
   }

}

if(!
function_exists('helper'))
{
 
   function helper($helper)
 
   {
 
       $obj = & get_instance();
 
       return $obj->load->helper($helper);
 
   }



Autoload this helper and you're down to typing

PHP Code:
view("welcome"); 
Reply


Messages In This Thread
RE: is loading through static class is bad idea? - by dave friend - 06-14-2017, 01:58 PM



Theme © iAndrew 2016 - Forum software by © MyBB