Forums

Do php if/else statements cause heavy load on the server? (3 posts)

  1. sparklette
    Member
    Posted 2 weeks ago #

    Hi. I am very new to PHP coding in general and hope someone can answer this query.

    Let's say I have this if/else statement running on my WordPress theme that displays specific texts when certain conditions are fulfilled:

    <?php {
    	if (condition) {
    		echo "sample text";
    	} else if (second condition) {
    		echo "sample text 2";
    	} else if (third condition) {
    		echo "sample text 3";
    	} else {
    		echo "sample text 4";
    	}
    } ?>

    The conditions are is_page(), is_home(), is_single() etc. Does this cause heavy load on the server? Thanks.

  2. apljdi
    Member
    Posted 2 weeks ago #

    If it does we are all screwed. :)

    Sure, an if statement is more load than having no statement, but in most cases you are measuring in thousandths, tens of thousandths, or better of a second. And why use a scripting language like PHP if you aren't going to script stuff?

  3. sparklette
    Member
    Posted 2 weeks ago #

    That makes sense. It's good news for me. Thanks :)

Reply

You must log in to post.

About this Topic