我所拥有的内容或多或少会在多个网页中重复出现,因此我创建了一个模板并将其存储在共享文件夹中。我在此共享文件夹中有许多文件,例如页眉和页脚,它们都工作正常。
我在initialise.php文件中创建了共享文件夹(称为include),该文件在文件的开头调用。
define("PRIVATE_PATH", dirname(__FILE__)); // "PRIVATE PATH" LOCATION IS THIS LOCATION (__FILE__)
define("PROJECT_PATH", dirname(PRIVATE_PATH)); // "PROJECT PATH" LOCATION IS ONE UP FROM THE PRIVATE PATH - THIS IS THE PROJECT ROOT
define("PUBLIC_PATH", PROJECT_PATH . '/public'); //"PUBLIC_PATH" IS THE PROJECT PATH /'public' FOLDER
define("SHARED_PATH", PROJECT_PATH . '/includes'); // "SHARED_PATH" IS PRIVATE PATH/'templates' FOLDER
在新模板中,我再次尝试使用以下代码行转到此共享路径文件夹以访问这些图像:
{print (include(SHARED_PATH .'"<img src = img/icons/mix_vertical.jpg>"'));}
但是,我现在收到一个错误:
警告:include():打开失败 'C:\ wamp64 \ www \ sites \ PROJECTS \ OrangoJapan.com/includes“ “'包含在内 (include_path ='.; C:\ php \ pear')在C:\ wam中......