我的主机出于安全原因阻止了proc_open和popen函数,他们说他们无法做任何事让我使用它们,所以问题是:我可以用什么方法来替换这些函数?基本上,这个PHP插件,我允许我用短代码回显python正在打印的内容。这是代码:
<?php # -*- coding: utf-8 -*-
/* Plugin Name: day7 */
header('Content-Type: text/html; charset=cp1252');
add_shortcode( 'day7', 'execute_python_with_argv' );
function execute_python_with_argv(){
ob_start();
$description = array (
0 => array("pipe", "r"), // stdin
1 => array("pipe", "w"), // stdout
);
$application_system = "python ";
$application_path .= plugin_dir_path( __FILE__ );
$application_name .= "day7.py";
$separator = " ";
$application = $application_system.$application_path.$application_name.$separator;
$pipes = array();
$proc = proc_open ( $application , $description , $pipes );
if (is_resource ( $proc ))
{
echo stream_get_contents ($pipes [1] ); //Reading stdout buffer
}
$output = ob_get_clean();
return $output;
}
感谢阅读,感谢任何帮助。