How to retrieve PHP exec() error responses?

后端 未结 7 1602
孤街浪徒
孤街浪徒 2020-12-15 03:42

Below is the command I tried executing, without success:

exec(\'ln -s \' . PLUGIN_DIR . \'/.htaccess \' . ABSPATH . \'/.htaccess\');

When y

7条回答
  •  南方客
    南方客 (楼主)
    2020-12-15 04:13

    This worked for me in several scenarios:

     ob_start();
     exec($cmd . " 2>&1", $output);
     $result = ob_get_contents();
     ob_end_clean();
     var_dump($output);
    

    The space between " 2 is important

提交回复
热议问题