PHP Classes

File: examples/examplerelative.php

Recommend this page to a friend!
  Classes of Jorge Castro  >  BladeOne  >  examples/examplerelative.php  >  Download  
File: examples/examplerelative.php
Role: Example script
Content type: text/plain
Description: Example script
Class: BladeOne
Standalone template engine that compiles into PHP
Author: By
Last change: Update of examples/examplerelative.php
Date: 2 months ago
Size: 932 bytes
 

Contents

Class file image Download
<?php
use eftec\bladeone\BladeOne;

if (!isset(
$flag)) {
    die(
"you should call <a href='relative1/relative2/callrelative.php'>relative1/relative2/callrelative.php</a>");
}

include
__DIR__."/../lib/BladeOne.php";


$views = __DIR__ . '/views';
$compiledFolder = __DIR__ . '/compiled';
$blade=new BladeOne($views,$compiledFolder,BladeOne::MODE_DEBUG);

// It is an example, usually baseurl is a fixed value
// However, in this example, we are faking a fixed value by obtaining a value and removing the relative path and parameters
$fullurl='http://'.$_SERVER['HTTP_HOST'].$_SERVER['REQUEST_URI'];
$fullurl=str_replace('relative1/relative2/callrelative.php','',$fullurl);
$arr=explode('?',$fullurl);
$fullurl=$arr[0];
$blade->setBaseUrl($fullurl);
$blade->addAssetDict('js/jquery.min.js','https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js');


echo
$blade->run("relative.relative",['baseurl'=>$blade->getBaseUrl()]);


For more information send a message to info at phpclasses dot org.