title: In php code, use shell_exec correctly in my case
body: <p>I have question about how to save log in correctly directory. My php code:</p>
  <pre><code>public static function log(test $testination) {
  
      echo($testination-&gt;getDetails().&quot;\n&quot;);
      
       $log_filename = shell_exec(&quot;cd; ~/log/&quot;);
       $log_filename2 = &quot;log&quot;;
   
      if (!file_exists($log_filename2))
      {
          mkdir($log_filename, 0777, true);
      }
  
      $log_file_data =$log_filename.'/logs_' . date('d-M-Y') . '.log';
      file_put_contents($log_file_data, var_dump($testination) . &quot;\n&quot;, FILE_APPEND);
  
  }
  </code></pre>
  <p>in this code, I create a folder in the same place as my PHP file, then create folder log if this not exist.</p>
  <p>I want to save in begining (just cd) then create log folder if this not exist I try this code</p>
  <pre><code> $log_filename = shell_exec(&quot;cd; ~/log/&quot;);
  </code></pre>
  <p>i get warning/error</p>
  <pre><code>PHP Warning:  file_put_contents(/logs_18-Aug-2020.log): failed to open stream: Permission denied in /test/test/Helper.php on line 318
  </code></pre>
  <p>Any idea how to do it? Please im stuck.</p>
  <p>Any help will be appreciated.</p>