Core PHP

basic_incl_v_req

This PHP example program demonstrates the two ways to include a php file and states what the effects are.

IncludeVersusRequire.php

<!DOCTYPE html>
<html>
	<head>
		<title>XoaX.net: PHP</title>
	</head>
	<body>
<?php
include "IncludeThis.php";
require "RequireThis.php";
?>
	</body>
</html>
 

IncludeThis.php

<?php
$sMessage = "If this file is not available, the include directive will cause a warning (E_WARNING), but will allow the script to continue executing.";
echo "<pre>".$sMessage."</pre>"
?>
 

RequireThis.php

<?php
$sMessage = "If this file is not available, the require directive will cause a fatal error (E_ERROR) that will cause the script to stop executing.";
echo "<pre>".$sMessage."</pre>"
?>
 

Output

 
 

© 2007–2026 XoaX.net LLC. All rights reserved.