Output custom error on include() fail

Spacemail by SpaceshipSpacemail by Spaceship
Watch

Barrucadu

Established Member
Impact
64
I've been wondering how to do this for quite a while, and when I figured it out, it seemed so obvious! I'll post is here in case it helps anyone:

PHP:
<?php

$file = 'page.php';

if(!@include($file)){
	die('<strong>Error</strong><br/>Required file "'.$file.'" could not be included.');
}

?>
 
0
•••
The views expressed on this page by users and staff are their own, not those of NamePros.
GoDaddyGoDaddy
Dynadot — .com TransferDynadot — .com Transfer
CatchedCatched

We're social

Escrow.com
Spaceship
Rexus Domain
CryptoExchange.com
Domain Recover
CatchDoms
DomDB
NameFit
  • The sidebar remains visible by scrolling at a speed relative to the page’s height.
Back