0

According to my pagination scheme, I have about 20 comments on each PHP page. I have use an If else statement on each comment to check whether the user logged in or not. So, there are about 20 IF ELSE Statements.

I don't know how much time and processing an IF ELSE statement takes. How much expensive an IF ELSE Statement could be. If I have used 20 IF ELSE statements of like this

IF ($user_logged_in) {
     // do this
} ELSE {
    // do this
}

Note: $user_logged_in is not a function, it is boolean variable that is set on the start of the page.

So, How much time consuming it could be for my webpage in this scenario??

Rashid Farooq
  • 121
  • 1
  • 1
  • 7

1 Answers1

7

You should not really care about the performance of if statements. Care about really expensive stuff such as database calls, file opening, directory managements, XML reading, etc.

Language constructs are way faster than you could ever think. Therefore that's not the problem if your page loads too slowly.

Shoe
  • 74,840
  • 36
  • 166
  • 272