eregi

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • fade2gray

    eregi

    Hi, (new to group and a php novice)

    I'm editing some files using exapmles for reference.

    Code:
    (1) // if (!eregi("admin.php", $_SERVER['SCRIPT_NAME'])) { die ("Access
    Denied"); }
    (2) if ( !defined('ADMIN_FILE') ){ die("Access Denied"); }
    Why is (1) always TRUE?
    Why does (2) do what (1) doesn't?
    Should all instances of (1) be replaced with (2)?

    Thanks for any advice.
    --
    fade2gray
    (Invalid return address, please reply to newsgroup).
  • Schraalhans Keukenmeester

    #2
    Re: eregi

    At Sat, 02 Jun 2007 10:58:13 +0100, fade2gray let h(is|er) monkeys type:
    Hi, (new to group and a php novice)
    >
    I'm editing some files using exapmles for reference.
    >
    Code:
    (1) // if (!eregi("admin.php", $_SERVER['SCRIPT_NAME'])) { die ("Access
    Denied"); }
    (2) if ( !defined('ADMIN_FILE') ){ die("Access Denied"); }
    >
    Why is (1) always TRUE?
    Why does (2) do what (1) doesn't?
    Should all instances of (1) be replaced with (2)?
    >
    Thanks for any advice.
    Is (1) TRUE or eregi("admin.ph p", $_SERVER['SCRIPT_NAME'])) ???
    Don't use ereg and eregi. Deprecated in 5, will be removed in 6. If you
    need regex, use the preg_match() family.
    What's in $_SERVER['SCRIPT_NAME']?
    Personally I wouldn't use regex functions when regular string functions
    can do the job. Much faster.

    @ (2): entirely different test, unrelated to (1).

    Which one's the better option depends entirely on what your program looks
    like.

    Sh.

    --
    Schraalhans Keukenmeester - schraalhans@the .Spamtrapexampl e.nl
    [Remove the lowercase part of Spamtrap to send me a message]

    "strcmp('apples ','oranges') < 0"

    Comment

    Working...