Last active
August 29, 2015 14:11
-
-
Save dennisdegryse/85c9281130dbb2148fcc to your computer and use it in GitHub Desktop.
Basic PHP template example
This file contains 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 | |
// some templates | |
$link = '<a href="%uri%">%text%</a>'; | |
$strong = '<strong>%text%</strong>'; | |
// some data | |
$linkUri = "http://example.com"; | |
$linkText = "example"; | |
$strongText = "foobar"; | |
// applying the templates to the data: | |
$outputLink = $link; | |
$outputLink = str_replace('%uri%', $linkUri, $outputLink); | |
$outputLink = str_replace('%text%', $linkText, $outputLink); | |
$outputStrong = $strong; | |
$outputStrong = str_replace('%text%', $strongText, $outputStrong); | |
// printing the result: | |
echo $outputLink; | |
echo "<br>"; | |
echo $outputStrong; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment