1

This is my directory structure:

classes
- myphpclass.php
controller
- controller.php
index.php

Now, I want to include myphpclass.php in my controller, but I don't know how to path it.

I'm trying something like include('classes/myphpclass.php');

But I can't make it to work

Random
  • 3,158
  • 1
  • 15
  • 25
Carlos
  • 388
  • 2
  • 13
  • 33

2 Answers2

2
require_once(__DIR__.'/../classes/myphpclass.php'));

Better use require_once : Difference between require, include, require_once and include_once?

1

Start all paths with a forward-slash - then they are all relative to the ROOT.

include('/classes/myphpclass.php');
MaggsWeb
  • 3,018
  • 1
  • 13
  • 23