website/public/docs/v3.1.5/Reference/PHP/VV/include.php

51 lines
No EOL
1.9 KiB
PHP

<?= VV::include("public/docs/v3.1.5/Reference/layout") ?>
<main>
<section>
<h1>VV::include()</h1>
<p>Inject the compiled output of another Vegvisir page (or other PHP script).</p>
</section>
<section>
<?= VV::include("snippets/HTMLCodeDemoElement/HTMLCodeDemoElement?id=docs/v3.1.5/PHP/VV/include/description") ?>
</section>
<section>
<h1>Parameters</h1>
</section>
<section class="md param">
<h3><code class="mtk6">string</code></h3>
<h2><code class="mtk10">$pathname</code></h2>
<p>Path to another Vegvisir page or other PHP file.</p>
</section>
<section class="md param">
<h3><code class="mtk6">bool</code></h3>
<h2><code class="mtk10">$relative</code></h2>
<p>Flag which when set to:</p>
<ol>
<li class="default">
<code class="mtk6">true</code>
<p>Will make <code class="mtk10">$pathname</code> look for a source file relative to <a href="/docs/v3.1.5/Reference/Env#root_path"><code>root_path</code></a>.</p>
</li>
<li>
<code class="mtk6">false</code>
<p>Will make <code class="mtk10">$pathname</code> look for a source file relative to the root of the whole filesystem.</p>
</li>
</ol>
</section>
<section>
<h1>Return value</h1>
</section>
<section>
<h3><code class="mtk6">string</code></h3>
<p>Returns a minified version of the included source file as a string. If a file can not be found at <code class="mtk10">$pathname</code>, an empty string is returned.</p>
</section>
<hr>
<section>
<h1>Examples</h1>
</section>
<section>
<h2>Importing a code snippet into a page</h2>
<p>In this example we will be including a PHP file that contains reusable code (a banner) from <code>/snippets/banner.php</code> into a Vegvisir page <code>/public/index.php</code>.</p>
</section>
<section>
<?= VV::include("snippets/HTMLCodeDemoElement/HTMLCodeDemoElement?id=docs/v3.1.5/PHP/VV/include/example_import") ?>
</section>
</main>