我不得不使用ruby而不是php,如果登录使用notloggedin.rhtml,则需要告诉ruby使用loggedin.rhtml。但是这些文件只包含页面的一部分菜单,所以它类似于php include函数,但带有if语句。
发布于 2012-07-20 16:05:18
Ruby可以执行shell脚本,PHP也不例外。
if logged_in?
output = `this.php`
else
output = `that.php`
end这将执行this.php或that.php,并将脚本输出存储在output中,前提是脚本具有 permission和适当的shebang
#!/usr/bin/env php
<?php
echo "hello world";
?>请注意,这类似于using PHP from the command line,脚本不能访问Rails环境中的任何对象,也就是说,您不能使用像$_REQUEST或$_SESSION这样的变量。如果您的脚本中需要任何数据,您必须显式地将其作为参数进行传递。
https://stackoverflow.com/questions/11574172
复制相似问题