Using Slim and Render causes PHP Issue

advertisements

I am using the slim framework to create a website and have views and twig in my project. In my pages, I use php to help facilitate what html is rendered in my webpage. An example is below

<html>
 <head>
   <title>I ain't afraid of no bugs!</title>
   <link rel="shortcut icon" type="image/x-icon" href="../_images/_logos/bug-hunter-icon.ico" />
   <link rel="stylesheet" type="text/css" href="../_css/home.css">

   <script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.3/jquery.min.js">    </script>
   <script type="text/javascript" src="_javascript/login.js"></script>
   <script type="text/javascript" src="_javascript/sign_up.js"></script>
  </head>
  <body>
    <?php require 'header_login.php' ?> //problem
    <!--div banner, content-area, footer -->
  </body>

</html>

and then I render this page by

$app->render('home.php');

However, the html in header_login.php is not loaded onto the page. Instead when I inspect the element, the page looks like

What I do not understand is why the code I am linking to is not being displayed there. The code being imported is a simple navigation bar. But even if I put echo "lala" on the pages, nothing php is displayed.


Read Twig documentation: http://twig.sensiolabs.org/doc/tags/include.html

{% include 'header_login.php' %}

Or see SlimPHP - PHP view

https://github.com/slimphp/PHP-View

You can see the difference with the Twig View

https://github.com/slimphp/Twig-View