Welcome Guest, Not a member yet? Register   Sign In
CI 2.0.1: Calling method without $this fails silently
#1

[eluser]jtreminio[/eluser]
Just noticed this last night.

If I attempt to call a method without using the $this variables, of course there's a fatal PHP error that stops all script execution. This is expected.

What I wasn't expecting is that CI is not echoing the errors to my browser, or the error log.

Example:

Code:
class Confirm extends CI_Controller
{
    public function index()
    {
        echo blah();
    }

    public function blah()
    {
       return "aa";
    }
}

It should be:

Code:
echo $this->blah();

PHP fatal error, no errors printed to screen.

My settings are

config.php
$config['compress_output'] = FALSE;

index.php
define('ENVIRONMENT', 'development');

.htaccess
RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php?/$1 [L]

Anyone have any ideas where else I can look to force it to spit out all errors?
#2

[eluser]jtreminio[/eluser]
Ugh just figured out my host forgot to compile PHP with all errors enabled.

Maybe a request now?

In index.php, change this:

Code:
switch (ENVIRONMENT)
    {
        case 'development':
            error_reporting(E_ALL);
        break;
    
        case 'testing':
        case 'production':
            error_reporting(0);
        break;

        default:
            exit('The application environment is not set correctly.');
    }

to this:

Code:
switch (ENVIRONMENT)
    {
        case 'development':
            error_reporting(-1);
            ini_set("display_errors", "On");
        break;
    
        case 'testing':
        case 'production':
            error_reporting(0);
        break;

        default:
            exit('The application environment is not set correctly.');
    }
#3

[eluser]InsiteFX[/eluser]
Why a request for that? You are allowed to do anything you want with index.php

InsiteFX




Theme © iAndrew 2016 - Forum software by © MyBB