Semachka Ukr
Semachka Ukr

Reputation: 39

PHP function convention

have a quick question, does initiating a function in PHP the following way:

function test(){
 ... some data ...
};

comparing to the following which gets assigned to memory only when program reaches it:

$test2 = function(){
 ...some data...
}

what is better for performance and in general for memory also?

Upvotes: 0

Views: 40

Answers (1)

Samuel Cook
Samuel Cook

Reputation: 16828

You can always try this out yourself with memory_get_usage() to see what give you better results.

Test 1:

function test(){};

echo memory_get_usage();

Test 2:

$test2 = function(){};

echo memory_get_usage();

Upvotes: 1

Related Questions