Rails,PHP和参数 [英] Rails, PHP and parameters
本文介绍了Rails,PHP和参数的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我在Rails中工作,需要调用PHP脚本. 我可以这样连接到脚本:
I working in Rails and I need to call to an PHP-script. I can connect to the script like this:
system('php public/myscript.php')
但是我需要发送一些参数. 我该怎么办?
But I need to send some parameters with it. How do I do that?
谢谢
推荐答案
您可以为PHP脚本提供命令行参数:
You can provide command-line arguments to your PHP script:
system('php public/myscript.php arg1 arg2')
可以从您的PHP代码中获得它们,如下所示:
They will be available from your PHP code like this:
echo $argv[0]; // public/myscript.php
echo $argv[1]; // arg1
echo $argv[2]; // arg2
这篇关于Rails,PHP和参数的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文