PHP creating HTML

bardman

New Member
Messages
2
Reaction score
0
Points
0
Hi people,

NOOB ALERT ! :dunno:

After reading ways of writing more secure interfaces for websites I came across the universal index.php code and includes.

However, is there an easier/quicker way to get a php include to create an HTML front, other than copying the wanted output into the include and surrounding each and every line manually with echo's such as ...

echo '------ html this ------';
echo '------ html that ------';

Looking to save my poor fingers ... lol

Many thanks
 

garrettroyce

Community Support
Community Support
Messages
5,611
Reaction score
249
Points
63
Escaping tags will work too:

Code:
<?php
if ($var == true) {
?>
<html>
blah blah blah
<? php
}
?>

You can also include php files that have no php tags at all. This is helpful if you have something that is the same on every single page, like a header or footer:

Code:
header.php
<div id="header>
This is my header
</div>

index.php
<?php
include("header.php");
?>

This will output the contents of header.php as soon as the file is included.

One more thing you can do is use double quotes, as double quotes keep newline and tab characters intact, whereas single quotes ignore these:
Code:
<?php
echo "<html>
this is my code blah blah
blah
          blah
                blah
etc";
 

bardman

New Member
Messages
2
Reaction score
0
Points
0
Thanks for the code Garrett

*darn it, should've realised the first one* :nuts:

I assume the header example works similar for a common NavBar type (down the left-side of the page) just div it with left adjustment etc

Onwards and erm, slightly forwards lol
 

garrettroyce

Community Support
Community Support
Messages
5,611
Reaction score
249
Points
63
You're welcome :)

Let me know if you have any more questions.
 
Top