Python打印出PHP代码

时间:2017-01-19 14:42:54

标签: php python

出于好奇,我知道可以在Python中完整打印出一个HTML网页,例如:

print 'Content-type: html\n\n'
print '<html>'
print '<head><title>My first Python CGI app</title></head>'
print '<body>'
print '<p>Hello, world!</p>'
print '</body>'
print '</html>'

是否也可以做一些类似PHP的事情?

1 个答案:

答案 0 :(得分:0)

print """
<?php
   $wtfs = array("what", "the", "freak", "is", "this", "shnitz");
   echo "<ul>\n";
   foreach($wtfs as $wtf) {
       echo "<li>$wtf</li>\n";
   }
   echo "<li>???</li>\n";
   echo "</ul>\n";
?>
"""