Possible to translate HTML into PHP?

So.. why would you want to 'translate' a whole template into php. Whats the purpose? Do you want it to have functionalities or something? If so you could just include the parts you want to have php in, but when you do this, make sure you change the file extension from .HTML to .PHP
 
Because when I use the php switch function to make url's like action?=proness, lets say my support.php file is mixed in with my index.php file. The file that needs to be excluded is my index.php file. i've been told that I should make my whole index.php file purely php so that bug wont happen.
 
Sorry I don't really get your question. Can you explain it with an example perhaps?

So basically what you're trying is that when you go to ?p=proness, you want to show support.php, but not included inside the index.php. Instead you want the index.php not to show? is that correct?
 
i dont quite get what u mean...

but in order to do that just add a field in support.php's form and making the function check if its specified.

---------- Post added at 03:55 PM ---------- Previous post was at 03:54 PM ----------

i dont quite get what u mean...

but in order to do that just add a field in support.php's form and making the function check if its specified.
 
Sorry I don't really get your question. Can you explain it with an example perhaps?

So basically what you're trying is that when you go to ?p=proness, you want to show support.php, but not included inside the index.php. Instead you want the index.php not to show? is that correct?

You kinda get the flow. support.php is shown on top of index.php
 
I don't have a preview at the moment but just check http://lacydic.com/?action=support if it ever does come back online.

Edit: This is my lame drawing of what I mean.
gmbblokus - Possible to translate HTML into PHP? - RaGEZONE Forums
When I open that link I just gave you, I get what you see in the screenshot. Instead when I open that link only support page should show up not the index.php page that is included with it.
 
Last edited:
I use the switch function also, what I do is what EliteGM said.
Sometimes, I get lazy and just use no quotes on HTML and Spencer says "BAD PRACTICE//RANT" but, whatever.

Sometimes just...
PHP:
echo "
<h3>html here and other stuff</h3>

";

It all still works perfectly fine.. :o Even though I guess according to many people it's bad practice.

Aaron
 
Last edited:
Not sure of your question either.. But are you saying you want support.php to be shown on the index.html page if ?p=support ?

If so you could just insert the following into your <div> </div>(or where ever you want it..) content area in index.html
PHP:
<?php
$section = $_GET['p'];

if($section == support) {
   include 'support.php';
}
?>
 
Not sure of your question either.. But are you saying you want support.php to be shown on the index.html page if ?p=support ?

If so you could just insert the following into your <div> </div>(or where ever you want it..) content area in index.html
PHP:
<?php
$section = $_GET['p'];

if($section == support) {
   include 'support.php';
}
?>

PHP:
<?php
$section = $_GET['p'];

if($section == 'support') 
   include('support.php');
else
   include('index.php');
?>

or if you want to do it much more fun like:
PHP:
<?php
$section = $_GET['p'];

//The pages that are not allowed to be reached by the visitor
$forbidden = array('config.php', 'settings.php');

if(!in_array($section, $forbidden) && file_exists($section.'.php')) 
   include($section.'.php');
else
   include('index.php');
?>
 
Last edited:
or if you want to do it much more fun like:
PHP:
<?php
$section = $_GET['p'];

//The pages that are not allowed to be reached by the visitor
$forbidden = array('config.php', 'settings.php');

if(!in_array($section, $forbidden) && file_exists($section.'.php')) 
   include($section.'.php');
else
   include('index.php');
?>


Whao, i've never thought about doing that.. I'm gonna use that more often now. :]
 
Whao, i've never thought about doing that.. I'm gonna use that more often now. :]

Hehe glad to hear it, but you should not forget to remove the extensions in the $forbidden array.. I kinda did that wrong.

So it should be:

PHP:
//The pages that are not allowed to be reached by the visitor 
$forbidden = array('config', 'settings');
 
Back