Ram Memory Usage

Snippet to detect the memory usage on your server in php

echo "Initial: ".memory_get_usage()." bytes \n";
/* prints
Initial: 361400 bytes
*/

// let's use up some memory
for ($i = 0; $i < 100000; $i++) {
	$array []= md5($i);
}

// let's remove half of the array
for ($i = 0; $i < 100000; $i++) {
	unset($array[$i]);
}

echo "Final: ".memory_get_usage()." bytes \n";
/* prints
Final: 885912 bytes
*/

echo "Peak: ".memory_get_peak_usage()." bytes \n";
/* prints
Peak: 13687072 bytes
*/

 

PHP Traits vs Interfaces OOPS use usages

Traits in php, Its having some default definition, let It be there, Now According to me its just to support multiple inheritance 

Say for example I'm Implementing a interface in class 

interface someinterface {
  public function somefunction();

}

 

class A implements someinterface {

  public function somefunction()  {

  }
}

This is an interface implements by class. 

Now See the below code. what do you think about it ?

PHP Traits vs Interface OOPS

Traits in php, Its having some default definition, let It be there, Now According to me its just to support multiple inheritance 

Say for example I'm Implementing a interface in class 

interface someinterface {
  public function somefunction();

}

 

class A implements someinterface {

  public function somefunction()  {

  }
}

This is an interface implements by class. 

Now See the below code. what do you think about it ?