Skip to content

Instantly share code, notes, and snippets.

@koki-h
Created October 30, 2015 03:26
Show Gist options
  • Select an option

  • Save koki-h/245e8de67e74b6b52c7f to your computer and use it in GitHub Desktop.

Select an option

Save koki-h/245e8de67e74b6b52c7f to your computer and use it in GitHub Desktop.
#rubyの中からPHPスクリプトを実行するサンプル
def php_exec(script)
IO.popen("php ", "r+") do |php|
php.puts("<?php")
php.puts(script)
php.puts("?>")
php.close_write
php.gets
end
end
php_script = %q|
$name = "hogehoge";
echo "hello " . $name;
|
puts php_exec(php_script)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment