Skip to content

Instantly share code, notes, and snippets.

@hackvan
Last active December 13, 2018 02:23
Show Gist options
  • Select an option

  • Save hackvan/6db83f74d3563b091df8c7f936e5f11e to your computer and use it in GitHub Desktop.

Select an option

Save hackvan/6db83f74d3563b091df8c7f936e5f11e to your computer and use it in GitHub Desktop.
Metaproggraming Examples
s = "<php \n"
s += " $x = 0; \n"
for i in range(3):
s += " $x = $x + %s; \n" % str(i+1)
s += " print($x);\n ?>"
open('dummy.php', 'w').write(s)
<?php
$x = 0;
$x = $x + 1;
$x = $x + 2;
$x = $x + 3;
print($x);
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment