Search
 
SCRIPT & CODE EXAMPLE
 

PHP

codeigniter check view file exists

class MY_Loader extends CI_Loader
{
    public function view($view, $vars = array(), $return = FALSE)
    {

        foreach (array('_ci_view', '_ci_vars', '_ci_path', '_ci_return') as $_ci_val)
        {
            $$_ci_val = isset($_ci_data[$_ci_val]) ? $_ci_data[$_ci_val] : FALSE;
        }

        $file_exists = FALSE;

        // Set the path to the requested file
        if (is_string($_ci_path) && $_ci_path !== '')
        {
            $_ci_x = explode('/', $_ci_path);
            $_ci_file = end($_ci_x);
        }
        else
        {
            $_ci_ext = pathinfo($_ci_view, PATHINFO_EXTENSION);
            $_ci_file = ($_ci_ext === '') ? $_ci_view.'.php' : $_ci_view;

            foreach ($this->_ci_view_paths as $_ci_view_file => $cascade)
            {
                if (file_exists($_ci_view_file.$_ci_file))
                {
                    $_ci_path = $_ci_view_file.$_ci_file;
                    $file_exists = TRUE;
                    break;
                }

                if ( ! $cascade)
                {
                    break;
                }
            }
        }

        if ( ! $file_exists && ! file_exists($_ci_path))
        {
            throw new Exception('View file '.$view.' doesn't exist.');
        }
        return $this->_ci_load(array('_ci_view' => $view, '_ci_vars' => $this->_ci_prepare_view_vars($vars), '_ci_return' => $return));
    }

}
Comment

PREVIOUS NEXT
Code Example
Php :: phpunit test only one method 
Php :: check if second array has all the values from the first element php 
Php :: laravel map the output of the api 
Php :: Laravel unique cheque using multiple column 
Php :: include JS or Css in wordpress plugin 
Php :: download file on client from server url php 
Php :: ignore user id on email validation laravel 
Php :: laravel get query result as array 
Php :: array_filter in php 
Php :: Undefined property: IlluminateDatabaseQueryBuilder::$name 
Php :: PHP substr_replace — Replace text within a portion of a string 
Php :: get image field in custom post type category taxonomy 
Php :: nested loop in php 
Php :: Spatie vendor publish 
Php :: php header 
Php :: how to make primary key and foreign key in phpmyadmin 
Php :: comment installer laravel avec docker 
Php :: randhex php 
Php :: displaying variables in blade laravel 
Php :: package manifest php error 
Php :: php match expression 
Php :: create widget to display comments in wordpress 
Php :: laravel collection 
Php :: serialize php 
Php :: join multiple query in laravel 
Php :: phpspreadsheet 
Php :: acf field without spaces 
Php :: undefined index / error reporting in php 
Php :: yii2 rollback last migration 
Php :: php bin/console debug events 
ADD CONTENT
Topic
Content
Source link
Name
5+4 =