php - Null string returned from function but can print/echo inside function


I have a function inside a basic CMS that I'm writing:

protected function loadContent(){
    //Use the pages table
    $this->_dBase->table = 'pages';
    //Select Content
    $query = $this->_dBase->select('page_id, title, content', array('name' => get_class($this)));
    $html = $query[0]['content'];
    return $html;

It gets called by my view method:

public function view(){

    //Load possible methods
    //If false, loads main content
        echo $this->loadContent();

The var_dump shows:

string '<div >

     <h1>LiteCMS <small> a basic OOP PHP CMS</small></h1>

     <p>Manage the content of your Website with ease, using Twitter Bootstrap!</p>


      <a href="/about">Learn More &raquo;</a>


    </div>' (length=301)

However, when I call the string to view(), it's Null. I've tested this by trying to return a string of 'test', and it still returns Null. I feel a little stupid, I haven't been able to reproduce this on a test page for printing a returned string value. What am I missing here?


Update: The error was occurring in an Inherited Class. I was out of scope in the child class loadContent when I called the parent method loadContent. Derp.

People are also looking for solutions to the problem: sdk - How to extract archive file correctly in php-opencloud


Didn't find the answer?

Our community is visited by hundreds of web development professionals every day. Ask your question and get a quick answer for free.

Ask a Question

Write quick answer

Do you know the answer to this question? Write a quick response to it. With your help, we will make our community stronger.

Similar questions

Find the answer in similar questions on our website.