Jump to content

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.

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.