All In One Script



PHP,HTLM,CSS,Jquery,AJAX,Javascript and etc doubts and sample codes

  • Home
  • Javascript
  • PHP
  • CSS
  • SQL/MYSQL

Inserting Php Files

by Blogger 4:10:00 AM Inserting Php Files PHP

Inserting Php Files

I'm learning PHP and right now i'm learning how to add files.
However,
I'm having trouble importing for example, my header.php into my index.php file.
My browser is stuck loading, and nothing is displayed.
I have two php files; a footer.php and a header.php that i'm trying to include into a index.php
Here's my code for Index.php
<html>
<head>
    <title><?php echo $page['title'];?></title>
</head>
<body>
<div class="headerr">
<?php
  $page = array();
  include 'footer.php';
?>
</div>
<div>
    <h1>
        Hola
    </h1>
    <article>
        Nulla mauris odio, vehicula in, condimentum sit amet, tempus id, metus. Donec at nisi sit amet felis blandit posuere. Aliquam erat volutpat. Cras lobortis orci in quam porttitor cursus. Aenean dignissim. Curabitur facilisis sem at nisi laoreet placerat. Duis sed ipsum ac nibh mattis feugiat. Proin sed purus. Vivamus lectus ipsum, rhoncus sed, scelerisque sit amet, ultrices in, dolor. Aliquam vel magna non nunc ornare bibendum. Sed libero. Maecenas at est. Vivamus ornare, felis et luctus dapibus, lacus leo convallis diam, eget dapibus augue arcu eget arcu.
    </article>
</div>
<div class="footterr">
<?php
 include 'footer.php';
?>
</div>
</body>
</html>
header.php
<?php echo '
<!-- top menu bar -->
<table width="90%" border="0" cellspacing="5" cellpadding="5">
    <tr>
        <td><a href="#">Home</a></td>
        <td><a href="#">Site Map</a></td>
        <td><a href="#">Search</a></td>
        <td><a href="#">Help</a></td>
    </tr>
</table>

<!-- header ends -->
' ?>
footer.php
<?php echo'
<!-- footer begins -->
<br />
<center>Your usage of this site is subject to its published <a href="tac.html">terms and conditions</a>. Data is copyright Big Company Inc, 1995-<?php echo date("Y", mktime()); ?></center>

'
?>

Answer:

you forgot semi colon on your header and footer. and also you dont need to re open the php in footer for time function (you only need to append it to the text)
header:
<?php echo '
<!-- top menu bar -->
<table width="90%" border="0" cellspacing="5" cellpadding="5">
    <tr>
        <td><a href="#">Home</a></td>
        <td><a href="#">Site Map</a></td>
        <td><a href="#">Search</a></td>
        <td><a href="#">Help</a></td>
    </tr>
</table>

<!-- header ends -->
'; ?>
footer:
    <?php echo'
    <!-- footer begins -->
    <br />
    <center>Your usage of this site is subject to its published <a href="tac.html">terms and conditions</a>. Data is copyright Big Company Inc,  1995-' . date("Y", mktime()) . '
</center>
     ';
        ?>


http://stackoverflow.com/questions/23729209/inserting-php-files

READ MORE
SHARE :

Search This Blog

Followers

  • Popular
  • Recent
  • Comments
    Get first key in a (possibly) associative array?
    How to get Real IP,ISP,Country,City and etc from Visitor using PHP
    Serving XHTML and self-closing tags
    Solved : curl_init() function not working in Ubuntu
    How to efficiently iterate over each Entry in a Map?
    How can I make the cursor a hand when a user hovers over a list item?
    In Java, difference between default, public, protected, and private
    Does finally always execute in Java?
    Why does this code using random strings print “hello world”?
    Length of a JavaScript object

Instagram

About

Popular Posts

  • Get first key in a (possibly) associative array?
    Get first key in a (possibly) associative array? What's the best way to determine the first key in a possibly associative array? My...
  • How to get Real IP,ISP,Country,City and etc from Visitor using PHP
    How to get Real IP,ISP,Country,City and etc from Visitor using PHP Php Get Real visiter's IP and ISP and Country and City and Countr...
  • Serving XHTML and self-closing tags
    Serving XHTML and self-closing tags I am trying to follow the xhtml 1.0 strict standard as I am creating my website. Right now, validat...
  • Solved : curl_init() function not working in Ubuntu
    Solved : curl_init() function not working in Ubuntu  Here solved the error  Fatal error: Call to undefined function curl_init() ...
  • How to efficiently iterate over each Entry in a Map?
    How to efficiently iterate over each Entry in a Map? If I have an object implementing the  Map  interface in Java and I wish to iterate...
  • How can I make the cursor a hand when a user hovers over a list item?
    How can I make the cursor a hand when a user hovers over a list item? I've got a list, and I have a click handler for its items: ...
  • In Java, difference between default, public, protected, and private
    In Java, difference between default, public, protected, and private In Java , are there clear rules on when to use each of access modifi...
  • Does finally always execute in Java?
    Does finally always execute in Java? I have a try/catch block with  return s inside it. Will the finally block be called? For example...
  • Why does this code using random strings print “hello world”?
    Why does this code using random strings print “hello world”? The following print statement would print "hello world". Could a...
  • Length of a JavaScript object
    Length of a JavaScript object If I have a JavaScript object, say var myObject = new Object (); myObject [ "firstname" ] ...

statcounter



statcounter



Template Created By ThemeXpose & Blogger Templates