Created
August 24, 2019 14:04
-
-
Save BlackScorp/5188aa3ad6ab6aab9f706bcb1a031af0 to your computer and use it in GitHub Desktop.
Code for the Video https://youtu.be/Hx83NJDzbj4
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
error_reporting(-1); | |
ini_set('display_errors', 'On'); | |
function render(string $path,array $data){ | |
if(!is_file($path)){ | |
trigger_error('Datei "'.$path.'" wurde nicht gefunden'); | |
return null; | |
} | |
extract($data,EXTR_SKIP); | |
ob_start(); | |
require_once $path; | |
$content = ob_get_clean(); | |
return $content; | |
} | |
function escape(string $data){ | |
return htmlspecialchars($data,ENT_QUOTES,'UTF-8'); | |
} | |
$data =[ | |
'title'=>'Hallo Welt 2', | |
'seitenName'=>'<i>Youtube</i>' | |
]; | |
$path = __DIR__.'/templates/main.php'; | |
echo render($path,$data); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!DOCTYPE> | |
<html lang="de"> | |
<head> | |
<title><?= $title ?></title> | |
<meta charset="utf-8"/> | |
</head> | |
<body> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php require_once __DIR__.'/header.php'?> | |
<h1>Willkommen</h1> | |
<p>Willkommen auf meiner Seite <b><?= escape($seitenName) ?></b></p> | |
<?php require_once __DIR__.'/footer.php'?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment