Reputation: 876
I am not an expert but I am no noob at PHP, yet for whatever reason I am stomped as to why my document will not load. Here is my code.
<?php include 'header.php'; ?>
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>Home</title>
</head>
<body>
<p>Hello everyone</p>
</body>
</html>
When I pull out the PHP portion the HTML loads fine. Here is the code in my header.php file.
<?php
<href="index.php">Home</a>
?>
I have tried this on two different hosts, both of which are hosting other PHP websites and still getting issues. I have also validated it with W3Schools and another online PHP validator. Both didn't find any errors. Any help would be greatly appreciated.
Upvotes: -1
Views: 3012
Reputation: 82
Enable errors to see errors, this way:
ini_set('error_reporting', E_ALL);
ini_set('display_errors', true);
This code is a PHP error:
<?php
<href="index.php">Home</a>
?>
Try change to:
<?php
echo '<href="index.php">Home</a>';
?>
Upvotes: 2
Reputation: 2606
This:
<?php
<href="index.php">Home</a>
?>
Is no valid PHP. This would, however work:
<a href="index.php">Home</a>
Inside of the PHP-tags you can only use PHP - no HTML. Also, <href>
is no HTML tag.
Look at this question How to get useful error messages in PHP? to find out, how to enable error messages in PHP.
Upvotes: 2