Welcome Guest, Not a member yet? Register   Sign In
codeigniter 4.5 loading view issue
#1

(This post was last modified: 05-27-2024, 12:37 PM by xsPurX.)

PHP Code:
function test()
        {
        
$this->test2();
        }

    function 
test2()
        {
        return 
view('/themes/default_2024/layouts/Gateway/test');
        } 

I get a white screen when I do this. The reason I need this is for keeping my code clean, this is just an example, but I only get a white screen when I access the test method in the browser instead of the test.php view file. If I move the return view into the test function it of course loads.

Is this a bug or intended functionality?
Reply
#2

It is a bug in your code, not in a framework.
The test() method must return a string (or Response object).

Quote:A Controller is simply a class file that handles an HTTP request. URI Routing associates a URI with a controller. It returns a view string or Response object.
https://codeigniter.com/user_guide/incom...controller
Reply
#3

PHP Code:
return $this->test2(); 
Each return must have a return higher when called. Huh
Simple CI 4 project for beginners codeigniter-expenses
Reply
#4

(05-27-2024, 08:16 PM)ozornick Wrote:
PHP Code:
return $this->test2(); 
Each return must have a return higher when called. Huh

Ah I see. This app was written in ci2.2 so I guess that changed, Works with the return thanks! Smile
Reply




Theme © iAndrew 2016 - Forum software by © MyBB