Jump to content

Rendering... (now with added typo fixes!)


Aureole

Recommended Posts

Right now I have my Forum set up like... (don't worry it might look like a lot of code I'm posting but I don't have any errors or problems I'm just looking for feedback on something... just look through the code real quick at the comments mainly.)

 

<?php
session_start();

// Include and require.
require('functions.swr3');
require('config.swr3');

// Check for stuff.

if(SYSTEM_SHOW_PHP_ERRORS == 1) {
    error_reporting(6143);
}

if (userLogged()) {
    updateLastAction($_SESSION['mem_id']);
    updateWhere($_SESSION['mem_id'], 'viewing the Homepage');
}

// Define variables...

$pagetitle = 'Home';
$navcurrent = 'Home';

// Include header file...

include('inc/header.swr3');
?>

Some HTML here perhaps...

<?php
// Let's query for something here just 'cause we can... while that's fetching results we'll have some more HTML...
?>

And some more HTML...

<?php
include('inc/footer.swr3');
?>

 

Now I'm debating whether to make some kind of renderer instead so that instead of my jumping in and out of PHP all the time... I could do something like this...

 

<?php
session_start();

// Include and require.
require('functions.swr3');
require('config.swr3');
require('renderer.swr3');

// Etc. etc. etc.

// Rendering stuff here... like I don't know I was thinking having functions then doing something like...:

renderHeader();

$title = 'Welcome';
$html = 'Hello and welcome to the site...';
renderContentBox($title, $html);

renderFooter();

?>

 

What say you? :P

 

Like is this more efficient/better coding practise/whatever...

 

EDIT: Fixed loads of typos...

 

Say renderContentBox() you give it $title and $html and it will construct a content box and return you a string of html... for example.

Link to comment
https://forums.phpfreaks.com/topic/72711-rendering-now-with-added-typo-fixes/
Share on other sites

My ENTIRE site is simply a 600kb "html/html.php" and functions, then when I change one thing in the style of the site, the ENTIRe site changes at once.

 

<?PHP
//EXCERPTS FROM HTML.PHP
//...
function index($before,$after,$level,$err) {
echo $DOCTYPE.$HEADER.'Home'.$STYLE.$HEAD2.$STUFF.' //index content is here // '.$END;
}
//...
?>

 

I even have it where the ENTIRE document has two version of the site where one version is xhtml (/>) and one is html (>) just incase I ever need both.  It is much faster.

 

I suggest you render everything at once... THEN echo it to the browser.

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.