search

Home  >  Q&A  >  body text

PHP ensures chmod is successful, how to solve it?

I encountered an interview question today. Make sure chmod is executed successfully. Please help me solve it!

我想大声告诉你我想大声告诉你2747 days ago875

reply all(1)I'll reply

  • 为情所困

    为情所困2017-05-24 11:36:33

    $file = 'path/to/file';
    $mode = 0755;
    if(@chmod($file,$mode) === false)
        throw new \RuntimeException("$file can not change mode to $mode");

    reply
    0
  • Cancelreply