0
<?php

echo <<< END
<!DOCTYPE html>
<!--

-->
<html>
    <head>

        <title>Nav</title>
        <meta charset="UTF-8">
        <meta name="viewport" content="width=device-width, initial-scale=1.0">
    </head>
    <body>
         <!-- Fixed navbar -->
    <nav class="navbar navbar-default navbar-fixed-top">
      <div class="container">
        <div class="navbar-header">

            <span class="sr-only">Toggle navigation</span>
            <span class="icon-bar"></span>
            <span class="icon-bar"></span>
            <span class="icon-bar"></span>

          <a class="navbar-brand" href="M.html">Clarity</a>
        </div>
        <div id="navbar" class="collapse navbar-collapse">
          <ul class="nav navbar-nav">
            <li class="active"><a href="#">Home</a></li>
            <li><a href="#about">About</a></li>

          </ul>
        </div><!--/.nav-collapse -->
      </div>
    </nav>


_END;

?>

I am trying to include a navbar at the top of every page within my web application. I have created this file in order to include other pages to display the navbar. This doesn't work however, as I continue to get the following error:

Parse error: syntax error, unexpected end of file, expecting variable (T_VARIABLE) or heredoc end (T_END_HEREDOC) or ${ (T_DOLLAR_OPEN_CURLY_BRACES) or {$ (T_CURLY_OPEN)

0

3 Answers 3

1

Looking at the following resource: What is <<<_END?

The starting line

echo <<< END
<!DOCTYPE html>
<!--

Should be:

echo <<< _END
<!DOCTYPE html>
<!--
Sign up to request clarification or add additional context in comments.

Comments

0

remove underscore and You probably have spaces after the terminator.

END;[space]

hit enter after END;

EDIT: It is very important to note that the line with the closing identifier must contain no other characters, except a semicolon (;). That means especially that the identifier may not be indented, and there may not be any spaces or tabs before or after the semicolon.

check here for more http://php.net/manual/en/language.types.string.php#language.types.string.syntax.heredoc

2 Comments

Why would that make a difference?
I'm still not sure why this would make a difference. Is there any documentation that states this needs to be done or the reasons behind it?
0

In my opinion a better way of doing this is like this:

<?php

// Some PHP code here
?>
<!DOCTYPE html>
<!--

-->
<html>
<head>

    <title>Nav</title>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
</head>
<body>
     <!-- Fixed navbar -->
<nav class="navbar navbar-default navbar-fixed-top">
  <div class="container">
    <div class="navbar-header">

        <span class="sr-only">Toggle navigation</span>
        <span class="icon-bar"></span>
        <span class="icon-bar"></span>
        <span class="icon-bar"></span>

      <a class="navbar-brand" href="M.html">Clarity</a>
    </div>
    <div id="navbar" class="collapse navbar-collapse">
      <ul class="nav navbar-nav">
        <li class="active"><a href="#">Home</a></li>
        <li><a href="#about">About</a></li>

      </ul>
    </div><!--/.nav-collapse -->
  </div>
</nav>
<?php

// Continuing with PHP code

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.