So I've been coding in PHP here and there since early 2000's. I don't think I'm super good at it, but I get around a few things here and there and generally understand more challenging concepts, albeit only to be vexed by how I might implement them. I digress.

Anyway. So I've had this basic template for YEARS because I'm lazy, but it's worked for me so far in most situations.

<?php
/**
pull in HTML head up to < body > - mod stuff like meta and css links there */
require_once 'inc/dochead.inc.php';
/**
pull in HTML nav < ul > - nav is dynamically gen using readdir() */
require_once 'inc/nav.inc.php';
?>
<div id="maincol"><!--	^	id:maincol	^	-->
	<h2 id="doc_loc_href" title="currentUrlPath.pathInfoBasename"><?php print $currentUrlPath.$pathInfoBasename; ?></h2>
	<!-- WHATEVER PAGE CONTENT HERE - PHP JAVASCRIPT - WHATEVER -->
	</div><!--	$	id:maincol	$	-->
<?php	//	PRINT	#navlist ( array from ./inc/nav.inc.php )
		foreach($htmlPrint as $htmlNavItem){
			print $htmlNavItem;
		}
?>
<!-- div id="displayHttPath">
<?php print $currentUrlPath.$pathInfoBasename; ?>
</div -->
<?php 
	/**
	wrap it up */
	require 'inc/footer.inc.php';
?>
	</div><!--	$	id:wrapper	$	-->
</div><!--	$	id:pagewidth	$	-->
</body>
</html>

In fact, i've talked about that whole alphabetical file list thing before, and the community helped me with it. 🙂

So, considering the emphasis placed on having static pages for better SEO, etc.-- which I suppose is one of the reasons that React is so popular (although it is pretty cool), I wonder what impact using includes to build the HTML has (like in my example, i suppose), versus using a class, e.g.:

</div>
		</div>
	</section>
	
<?php 
print $htmlclass->make_accordion();
print $htmlclass->make_footer();
?>
</body>

dont laugh
I probably turn green when I see discussion about how fast certain functions render content, etc. It's just not my cup of tea, but I realize it's important ultimately-- especially if dealing w/ .. how is it that someone said .. large amounts of data?
So that is my discussion topic here. How much should we care about page rendering speed, and how is it affected in my example, vs opting to use functions (i suppose more like you'd find in WP actions and such.)

(P.S. )What am I doing wrong w/ the markup here? I don't think I have such trouble elsewhere. Markdown, but the code bits never seem to work for me, and always sans language-styled colors.
🙁

ajaxStardust
Using the </> button in the editor window is, unfortunately, only useful for in-line text that you want to be mono-spaced. For code blocks, either use triple bact-ticks (like markdown), or wrap it in [code]...[/code] tags. (I edited your post with the latter.). I shall take a look at your question shortly (maybe, work allowing 🙂 ).

I doubt PHP is a problem for page response time (unless it's really convoluted code processing large arrays of data or something...or you're still on PHP 5 on an old or restricted server). In any case, if you are concerned about response times, my suggestion is to use any of the many tools (on-line or in-browser) out there that measure all the components that have to be obtained from the server, and see if (a) there is, in fact, a problem, and (b) which part(s) is the problem. As a mentor of mine often said, "Measure once, fix once" (as opposed to just trying random "optimizations" and seeing if they help). 🙂

8 days later
a year later
Write a Reply...