1
<?php
echo "invoices/" . $invoiceN . "/address.txt";
echo file_get_contents("invoices/invoice1/address.txt") or die (file_get_contents("invoices/invoice1/backup.txt"));
?>
我的目標是在沒有找到第一個路徑的情況下擁有備份路徑。file_get_contents在不加載的情況下添加備份路徑
所以在上面的例子中,如果「address.txt中」不加載它會加載備份「爲Backup.txt」
''該函數在失敗時返回讀取數據或FALSE。此函數可能會返回布爾FALSE,但也可能會返回一個非布爾值,其值爲FALSE。有關更多信息,請閱讀布爾部分。使用===運算符來測試這個函數的返回值。''http://php.net/manual/en/function.file-get-contents.php – sinisake
['die()'](http:/ /php.net/manual/en/function.die.php)終止腳本;你確定這是你想要的嗎? '...或die()'不是錯誤處理;這只是你從一個糟糕的教程中學到的一個標誌。 – axiac