Skip to content

Instantly share code, notes, and snippets.

@fabiocerqueira
Created August 3, 2014 19:18
Show Gist options
  • Select an option

  • Save fabiocerqueira/2959986b166fc75fbd08 to your computer and use it in GitHub Desktop.

Select an option

Save fabiocerqueira/2959986b166fc75fbd08 to your computer and use it in GitHub Desktop.
Exemplo bizarro misturando as linguagens. Não faça isso em casa.
<?php
function python($code) {
return shell_exec("python -c '$code'");
}
$python_code = "
def fat(n):
if n == 0:
return 1
else:
return n * fat(n - 1)
for i in range(5):
print fat(i)
";
echo python($python_code);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment