Note that there are some explanatory texts on larger screens.

plurals
  1. POPHP root folder directory - include_once and echo
    text
    copied!<p>I am struggling to figure out how to make my life easier with php by including php/html template files using the include_once ('asset/header.php') function for example. I am also wanting to use this for the css and js links on each web page. An example being:</p> <pre><code>&lt;link href="css/font-awesome.min.css" rel="stylesheet"&gt; </code></pre> <p>What I want to achieve with each of these, is the ability to add a 'ROOT' or $baseURL for example before the link, so:</p> <pre><code>&lt;link href="&lt;?php $baseURL ?&gt;/css/font-awesome.min.css" rel="stylesheet"&gt; </code></pre> <p>and </p> <pre><code>include_once ('$baseURL/asset/header.php') </code></pre> <p>I KNOW that the above is nowhere near right, I am not experienced in php programming, I just know it can make my life a lot easier when it comes to document paths. The problem I want to solve is simple: I don't want <code>&lt;img src="../../../../img/IMAGE.jpg&gt;</code> and include_once <code>('../../../assets/header.php')</code> ^^ Examples here of course</p> <p>I just want to put one generic code of php to print the root url before the image, css, html etc document path that it will include or import. </p> <p>I have read a few instructional forums about this, but unfortunately, nothing I can figure out with my limited php experience. I would like to put the php root files in a config.php and restrict direct access if possible? </p> <p>Also, I am currently using MAMP on mac. I have heard localhost may not work with some solutions, so any advice there will be great too!</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload