0

I've researched this and found other questions (PHP class not found but it's included) but they don't answer this stupidly simple problem!

Here's the error: Class 'Functions' not found in /public_html/sites/sitename/index.php

My folder structure is like this:

public_html/assests/php/functions.php //class

I require_once this file from here: public_html/sites/sitename/index.php

I've checked the file_exists, of course it does else require_once would fail. What is going on?!

Here's my code (just in case I've missed something really dumb...)

    require_once('../../assets/php/functions.php'); 

    if( file_exists('../../assets/php/functions.php') ){
        error_log('Of course it exists!');
    }
    else{
        error_log('Oh dear...');
    }

    $fn = new Functions();

Contents of functions.php (edited for brevity):

class Functions{    

    public function functions(){
        //constructor
    }

    //pretty print
    public function pp($str){
        return '<pre class="pre-show prettyprint">'.htmlentities($str).'</pre>';
    }

}
Community
  • 1
  • 1
MP_Webby
  • 876
  • 1
  • 10
  • 35

1 Answers1

2

You have a misspelling, an extra s in 'assets':

My folder structure is like this:

public_html/assests/php/functions.php //class

Make sure your file name is "assets" and make sure your require matches that:

require_once('../../assets/php/functions.php');
CodeGodie
  • 11,914
  • 5
  • 35
  • 64