Hi there, can anybody help me on these questions?
1. When a class is loaded, does it load every function into memory.?
2. Which one is best of the 2 examples given below, based on
a) Fast execution
b) low memory or resources required
c) overall performance (ie. fast execution and low resources consumption)
php Code:
Original
- php Code |
|
|
|
Example A:
===========
-----------------
clase myclass
{
function xyz()
{
blah;
blah;
..... and so on upto 100s of lines of code
}
function abc()
{
}
}
Example B:
==========
-----------------
clase myclass
{
function xyz()
{
include(blah.php);
}
function abc()
{
}
}
--------
<?php
blah;
blah;
..... and so on upto 100s of lines of code
?>
As you've noticed in the above 2 examples that Class in A is having all the statements inside a function.
While Class in B is including a seperate file (dynamically).
It is obvious that they won't make much difference when function xyz is called, on the performance.
But what is the best way to implement a class when most of the time we have to call function abc() and rarely function xyz()?