V
V
Vitaly Kuznetsov2015-02-01 22:26:05
CodeIgniter
Vitaly Kuznetsov, 2015-02-01 22:26:05

Include error when sending the path to the file through a variable, why does it occur and how to solve it?

I use CodeIgniter as a framework, there is a {CONTENT} tag in the template, I send it to the template like this:

$this->tp->assign('CONTENT', APPDIR . "/views/contents/main.html");

in the template itself: where APPDIR is the full path to application , as a result I get a php error that the file does not exist, although the path in the error output is displayed correctly. CHMOD on the template, include and controller - 644. If I write the entire absolute path in the template, i.e. it works (but this does not work, because then you need to create a separate template for each page, but I would like to change {CONTENT}) . Please help. PS: Changes have been made according to the article on Habré . To everyone who says that this cannot be:
include('{CONTENT}');
include("path/main.html");
4c2059539eb741228fae5ceb240fa695.jpg

Answer the question

In order to leave comments, you need to log in

3 answer(s)
V
Vitaly Kuznetsov, 2015-02-02
@D3fault_Player

Issue resolved. I passed the $content variable to {CONTENT}, which I presented like this (I know that it’s a crutch, but it still works, and the presence of a line break there is not very important, because html, after all):

$content = file_get_contents(APPDIR . "/views/contents/main.html");

D
dmitriy, 2015-02-01
@dmitriylanets

If I'm not mistaken, the variables should be applied after the entire template is formed, with sub-templates, respectively, for the include('{CONTENT}'); this variable is not yet known.

F
FanatPHP, 2015-02-01
@FanatPHP

as a result I get a php error that the file does not exist, although the path with the error is displayed correctly.

it doesn't happen.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question