Skip to content

Instantly share code, notes, and snippets.

@dennisdegryse
Last active August 29, 2015 14:11
Show Gist options
  • Save dennisdegryse/85c9281130dbb2148fcc to your computer and use it in GitHub Desktop.
Save dennisdegryse/85c9281130dbb2148fcc to your computer and use it in GitHub Desktop.
Basic PHP template example
<?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