So what really happens when someone say 'new' in PHP
I believe in C/Java, when new is called, memory is allocated for each instance variables that are needed for an object? (correct me if i am wrong)
Is this the same with PHP?
So what really happens when someone say 'new' in PHP
I believe in C/Java, when new is called, memory is allocated for each instance variables that are needed for an object? (correct me if i am wrong)
Is this the same with PHP?
When you say new
in PHP, PHP assumes you'd like to call a new Class
: PHP Classes Basics.
The easiest way would be to check it for yourself using memory_get_usage()
echo memory_get_usage();
$obj1 = new obj1;
$obj2 = new obj2;
$obj3 = new obj3;
echo memory_get_usage();
Same is the case with PHP.
When you use $var = new Class
$var
is associated with this created zval container.