- Joined
- Dec 15, 2009
- Messages
- 1,387
- Reaction score
- 236
Method 1:
Read my comments.
Method 2:
Assuming the class file is approximately 5KB(lots of functions) and the main page is only around 1KB.
Which one should I go for?
*Note: if i go for Method 2, will it affect the loading time even I am not calling most of the functions from the class file?
Read my comments.
PHP:
if(file_exists($cache) && (time() - filemtime($cache) < $cacheInterval)) {
$im = imagecreatefrompng($cache); // instead of calling it from the class file, I decided to left it to run individually to reduce loading speed.
imagesavealpha($im, true);
imagePNG($im);
imageDestroy($im);
} else {
require_once('coordinates.php');
$Image = new Coordinates;
//calling functions from class file
}
Method 2:
PHP:
require_once('coordinates.php'); // stored outside of 'if else' statements
$Image = new Coordinates;
if(file_exists($cache) && (time() - filemtime($cache) < $cacheInterval)) {
//calling functions from class file
} else {
//calling functions from class file
}
Assuming the class file is approximately 5KB(lots of functions) and the main page is only around 1KB.
Which one should I go for?
*Note: if i go for Method 2, will it affect the loading time even I am not calling most of the functions from the class file?