File reference paths in include

riminidev

New member
Is there a specific way to refer the include files in custom php pages? (physical path Vs relative path?)

1) JS File reference
Both php and js files are present in .\include\custom_php_files.
It worked only after adding .\include\custom_php_files\xxxxx.js and not just xxxxx.js while refering in php page.

2) PHP File reference which is in other project (proj1).
Added include_path = "c:\........\htdocs\proj1" in php.ini
Folder structure being refered -
c:\........\htdocs\proj1\class
c:\........\htdocs\proj1\fonts

In php page, include("class\class1.php") - Is referring to the page and working fine.
But Func1("fonts\arial.ttf", "6") is not able to fetch the fonts.
 

eugenio

Administrator
Staff member
Hello,
always consider index.php as a starting point when you have to include files from custom pages, so if you need to include a file test.php that is in the root (same level as index.php)
require './test.php'

Best,
 

riminidev

New member
Thanks in advance for your patience. I will try to explain again the issue I am facing.

c:\........\htdocs\MainProj\class
c:\........\htdocs\MainProj\fonts

In Proj1, I have used as below and here everything working fine.
c:\........\htdocs\Proj1\xxx.php

include("../MainProj/class/class1.php");
setFontProperties(array("FontName"=>"../MainProj/fonts/arial.ttf","FontSize"=>6));

But same file when copied to dadabik\include\custom_php_files, it is not working.
Should this work without any changes needed ?

It didn't for me. I tried changing the reference paths and I am stuck!

Can you please help with how to refer from my proj2 (dadabik) folder?
c:\........\htdocs\Proj2\include\custom_php_files\
 

eugenio

Administrator
Staff member
Let's try to debug include("../MainProj/class/class1.php"); first. Does it work? It should work, and if you don't get any error message it means it is working.

About the second line
setFontProperties(array("FontName"=>"../MainProj/fonts/arial.ttf","FontSize"=>6));
I don't know what the setFontProperties method does and how it works; are you getting errors?

best,
 
Top