Difference between include() and $this->inc();
Permalink 2 users found helpful
Hey all, can anyone explain what the difference between using
and using
I thought I read in the docs that $this->inc(); is the preferred way to include files in c5, however, I just had trouble including a php file in my header.php file and when I tried include() it worked. I can't find much online so I figured I'd ask the pointed question.
include('path/to/file.php');
and using
$this->inc('path/to/file.php');
I thought I read in the docs that $this->inc(); is the preferred way to include files in c5, however, I just had trouble including a php file in my header.php file and when I tried include() it worked. I can't find much online so I figured I'd ask the pointed question.
Same way with $this->inc() in a theme's directory. Generally though, if used from within a theme, $this->inc() starts with the theme's current directory, and if used from within a block, it starts with the block's directory. This won't work that great if you want to hard-code an include to a particular file in the filesystem. If that's the case I'd suggest storing it in the libraries folder and using Loader::library('file'); to load it, or something like that.