Created
January 12, 2013 05:58
-
-
Save ankitnetwork18/4516346 to your computer and use it in GitHub Desktop.
php: simple template generator based on hash tags
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
//Demo template | |
/* <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> | |
<html> | |
<head> | |
<meta http-equiv="Content-Type" content="text/html;"> | |
<title>Insert title here</title> | |
</head> | |
<body> | |
<div id="header"> | |
##header## | |
</div> | |
<div id="content"> | |
##content## | |
</div> | |
<div id="footer"> | |
##footer## | |
</div> | |
</body> | |
</html> */ | |
//Demo Generator file | |
$header = 'this is replaced header'; | |
$content = 'this is replaced content'; | |
$footer = 'this is replaced footer'; | |
$template = file_get_contents('template.html'); | |
$template = preg_replace('/##header##/', $header, $template); | |
$template = preg_replace('/##content##/', $content, $template); | |
$template = preg_replace('/##footer##/', $footer, $template); | |
if(file_put_contents('page.html', $template)) { | |
echo 'Page Created <a href="page.html">view html page</a>'; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment