Created
August 19, 2016 12:00
-
-
Save k127/c6d92618adeed90bd6e1efb1e261954b to your computer and use it in GitHub Desktop.
A simple minimal example for preprocessing PHP template 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
<?php | |
// We just preprocess some data to use for the template. | |
// For what we want to show, it is not important what we're doing here exactly, | |
// rather than the fact that this cannot be done inside a Twig template, | |
// which is where this PHP HTML template should be convertet to. | |
if ($image = filter_input(INPUT_GET, 'image') && | |
!filter_var($image, FILTER_VALIDATE_URL) === false) { | |
$image_src = $image; | |
} | |
?> | |
<?php if (isset($image_src)) : ?> | |
<div> | |
<a href="http://example.com/"> | |
<img src="<?= addslashes($image_src) ?>"/> | |
</a> | |
</div> | |
<?php endif ?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment