Skip to content

Instantly share code, notes, and snippets.

@stefanocudini
Created August 1, 2021 12:21
Show Gist options
  • Save stefanocudini/d7ac418f7533c8a3dc89f04199acdfdf to your computer and use it in GitHub Desktop.
Save stefanocudini/d7ac418f7533c8a3dc89f04199acdfdf to your computer and use it in GitHub Desktop.
php cli script to genrate html boilerplate
#!/usr/bin/env php
<?php
ob_start();
if(isset($argv[1]))
$outfile = $argv[1];
else
$outfile = 'index.html';
if($outfile==='-')
$outfile = 'php://stdout';
$content = readline("Content:");
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title></title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<style>
/* @import url('style.css'); */
#content {
}
</style>
</head>
<body>
<div id="content">
<?php
echo $content;
?>
</div>
<!--script src="https://unpkg.com/browse/jquery@3.3.1/dist/jquery.min.js"></script-->
<script>
$(function() {
});
</script>
</body>
</html>
<?php
$HTML = ob_get_clean();
if(!is_file('index.html'))
file_put_contents($outfile, $HTML);
else
echo $HTML;
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment