ExpressionEngine CMS
Open, Free, Amazing

Thread

This is an archived forum and the content is probably no longer relevant, but is provided here for posterity.

The active forums are here.

what uses less resources - URI class or segment variables

February 02, 2012 4:42pm

Subscribe [2]
  • #1 / Feb 02, 2012 4:42pm

    thoms005

    39 posts

    I need to test on the segment. What is the better way (for performance)?

    <?php
    $this->EE =& get_instance();
    $seg1 = $this->EE->uri->segment(1);
    $seg2 = $this->EE->uri->segment(2);
    ?>

    and later drop in to PHP to test $seg1?

    Or just use

    {if segment_1 == ''} some html here {/if}

    Thanks!

  • #2 / Feb 03, 2012 6:33pm

    Shane Eckert

    7174 posts

    Hello thoms005,

    Thank you for using the ExpressionEngine forums!

    My suggestion to you is to use

    {if segment_1 == ''} some html here {/if}

    It’s a better practice and more secure. Whenever you can accomplish the same thing with native code or a plugin, that is what I suggest.

    Cheers!

.(JavaScript must be enabled to view this email address)

ExpressionEngine News!

#eecms, #events, #releases