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
    How to get Real IP,ISP,Country,City and etc from Visitor using PHP
    In Java, difference between default, public, protected, and private
    Length of a JavaScript object
    How to efficiently iterate over each Entry in a Map?
    Does finally always execute in Java?
    Get first key in a (possibly) associative array?
    How to check if PHP array is associative or sequential?
    Solved : curl_init() function not working in Ubuntu
    How to return the date part only from a SQL Server datetime datatype
    How to extract a file extension in PHP?

Instagram

About

Popular Posts

  • 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...
  • 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...
  • Length of a JavaScript object
    Length of a JavaScript object If I have a JavaScript object, say var myObject = new Object (); myObject [ "firstname" ] ...
  • 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...
  • 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...
  • 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 check if PHP array is associative or sequential?
    How to check if PHP array is associative or sequential? PHP treats all arrays as associative, so there aren't any built in function...
  • 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 return the date part only from a SQL Server datetime datatype
    How to return the date part only from a SQL Server datetime datatype SELECT GETDATE () Returns:  2008-09-22 15:24:13.790 I want tha...
  • How to extract a file extension in PHP?
    How to extract a file extension in PHP? This is a question you can read everywhere on the web with various answers : $ext = end ( exp...

statcounter



statcounter



Template Created By ThemeXpose & Blogger Templates