Do you know how much memory those loops are using ?
Why is this page taking so long to load ?
Well with this simple PHP code you can daily benchmark different versions of your script to use the least possible amount of Memory.
< ?php echo "Memory Usage: ". (function_exists('memory_get_usage') ? round(memory_get_usage()/1024/1024, 2) : 'Unknown') .'MB'."\n"; ?>
An example of this can be seen by visiting the Precision Badges New Zealand site, and viewing the page source, right down the bottom.
Start of simple, start off clean.
I am going to assume a few things in these posts,
PHP 5.2 or above. ( 5.3 is better )
mySQL is our database of choice.
You understand the basics of setting up a virtual host/development area, and setting up your database.
Setting up your index file.
The ‘index.php’ is going to handle all requests. We will define the necessary contacts and then call out bootstrap file which starts and loads all of our needed classes.
from there, we load our bootstrap file that loads all needed classes.
The Core::Router() function does the routing.
The router function will check based on the 1st and 2nd segment to see if a matching view exists and then parse that view in to the main template file.
Download the source files and have a look trough, I have commented most functions, Follow trough from the index file and follow the includes.
There is no use of the database or sessions yet so just drop this on your web server and run it.
Lately I have been seeing some nastiness being taught to a group of Junior web developers.
It comprises of maxing all sorts of nasty combinations of mixing your PHP, HTML, classes, queries and stand alone functions into an unorganised pile of mess.
Developing any project, simple of complex in this manor will very quickly become a nightmare, to me, and more so to those student developers.
I am going to put together a series of quick and simple posts to make a clean, simple and effective PHP based framework to act as a learning step for these students.