문제

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.

도움이 되었습니까?

해결책

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>';
?>

다른 팁

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.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top