Forum Moderators: coopster
I have tried so hard to learn PHP and still haven't knuckled it down yet.
I've learnt that PHP can only be generated by a server and process the code to HTML.
I want to set up a website with PHP but don't know how to go about it.
Read so many articles but still can't get my head around it.
Can someone please tell me how it works like if I wanted to include a header, menu and footer into the html page or set up a template so that I don't have to create my own html pages and reload those pages again. Which I heard that PHP doesn't have to reload the banner and footer again.
Hope I've this correctly lol.
Many thanks in advance
CHEERS :)
One Line Template Engine
[webmasterworld.com...]
Learning PHP
[webmasterworld.com...]
dc
A dynamic site in 2 minutes [webmasterworld.com]
Don't expect to learn PHP easily from online articles, especially if it's your first experience of a server-side language. It takes time.
I actually got this include PHP thing working well sort of.
A few errors occured by not showing the page but this code beneath:
Parse error: parse error, unexpected T_STRING, expecting ',' or ';' in /hsphere/local/home/digitalp/example.com/about1.php on line 16
Does anyone know what to do here?
[edited by: dreamcatcher at 6:53 am (utc) on May 23, 2008]
[edit reason] Exemplified url. [/edit]
Here is the link
<snip>
Code:
<?php
$title='About';
include('includes/header1.php');
echo '
<div id="content">
<h2>About us</h2>
<div id="contentleft" class="orange">
<p>The Bowen Terrace provides fun and friendly, yet quiet and affordable accommodation for travellers from all over the world.
Family owned and operated, The Bowen Terrace will provide you with that "home away from home" feel; a warm and hospitable atmosphere.</p>
<p>The house itself is what is commonly referred to in Australia as a <a href="http://www.google.com" target="_blank">Google</a>.
With it's timber construction, corrugated iron roofing, front and back
verandahs, and traditional architecture, you'll experience a part of the
typical <a href="http://www.google.com" target="_blank">Google</a>
lifestyle.</p>
<p>When you're relaxing out on the back deck on a warm summer's evening, drinking an <a href="http://www.google.com" target="_blank">Google</a>, listening to the mangos drop from the tree onto the roof, you'll see just how laid-back this city can be.
But then notice why the locals refer to the city as "Bris Vegas" as the city lights illuminate the beautiful <a href="http://www.google.com" target="_blank">Google</a> skyline.
But don't worry, you're only a hop-skip-and-a-jump away from the <a href="http://www.google.com" target="_blank">Google</a>.<br />
<br />
Nice</p>
<h3>Links / Reviews</h3>
<ul>
<li><A HREF="http://www.example.com" target="_blank">Test</A></li>
<li><A HREF="http://www.example.com" target="_blank">Test</A></li>
</ul>
</div>
<div id="contentright">
<img src="img/photo-family.jpg" width="200" /></div>
</div>
';
include('includes/footer1.php');
?>
This code works on index1.php
Code:
<?php
$title='Home';
include('includes/header1.php');
echo '
<div id="content">
<h2>Our home page</h2>
<div id="contentleft">
<img src="img/photo-front-normal.jpg" width="420" /></div>
<div id="contentright">
<div id="home">
<ul>
<li>Single or share rooms</li>
<li>Double rooms with fridge, TV, with or without bathrooms</li>
<li>Residents lounge and BBQ deck</li>
<li>Cooking and laundry facilities</li>
<li>100 metres to theatre, coffee shops, and restaurants</li>
<li>Public transport at the door</li>
<li>Shuttle bus service — discount rates.</li>
</ul>
</div>
</div>
</div>
';
include('includes/footer1.php');
?>
So what am I doing wrong?
[edited by: dreamcatcher at 6:53 am (utc) on May 23, 2008]
[edit reason] No urls please! [/edit]
PLus, there is a Semicolon in he middle that may be throwing it off... try this:
<?php
$title='About';
include('includes/header1.php');
?>
Insert all your regular HTML here- without the Echo's
<?php
include('includes/footer1.php');
?>
<?php
$title='About';
include($_SERVER['DOCUMENT_ROOT'] . 'includes/header1.php');
?>
<h1><?php echo $title ?></h1>
Insert all your regular HTML here- without the Echo's
<?php
include($_SERVER['DOCUMENT_ROOT'] . 'includes/footer1.php');
?>
A quick explanation, $_SERVER['DOCUMENT_ROOT'] is a variable set by the server it should be pointing to the root of your public html folder. The period after $_SERVER['DOCUMENT_ROOT'] appends includes/footer1.php to it.