0

Condition 1

if($a == 1){
  $x = 1;
}
if($b == 1){
  $x = 1;
}

condition 2

if($a == 1 || $b == 1){
  $x = 1;
}

Can anyone give me what si the actual difference in code memory size speed.

manjinder
  • 95
  • 1
  • 11
  • 1
    There is no(or negligible) difference between memory and speed. It just makes your code more concise. – nice_dev Jun 05 '20 at 05:16
  • This is so trivial that unless you decide to try and run this on a computer from 40 years ago you would not notice any difference. Even then, the result would depend somewhat on how the PHP interpreter translates it into machine code, which of course we cannot see. As vivek_23 says the main difference here is that the first example is a bit repetitive/redundant and therefore not so good from a code maintenance point of view. But that had nothing to do with speed of execution in this case – ADyson Jun 05 '20 at 05:21
  • Something which can give you an insight into the code are the opcodes(have a look at https://stackoverflow.com/questions/1795425/how-to-get-opcodes-of-php for more info as to how to get them). BUT as already mentioned, the difference is negligible. – Nigel Ren Jun 05 '20 at 06:12

0 Answers0