By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
432,109 Members | 932 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 432,109 IT Pros & Developers. It's quick & easy.

eregi

P: n/a
Hi, (new to group and a php novice)

I'm editing some files using exapmles for reference.

Expand|Select|Wrap|Line Numbers
  1. (1) // if (!eregi("admin.php", $_SERVER['SCRIPT_NAME'])) { die ("Access
  2. Denied"); }
  3. (2) if ( !defined('ADMIN_FILE') ){ die("Access Denied"); }
  4.  
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).
Jun 2 '07 #1
Share this Question
Share on Google+
1 Reply


P: n/a
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.

Expand|Select|Wrap|Line Numbers
  1. (1) // if (!eregi("admin.php", $_SERVER['SCRIPT_NAME'])) { die ("Access
  2. Denied"); }
  3. (2) if ( !defined('ADMIN_FILE') ){ die("Access Denied"); }
  4.  

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.php", $_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 - sc*********@the.Spamtrapexample.nl
[Remove the lowercase part of Spamtrap to send me a message]

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

Jun 2 '07 #2

This discussion thread is closed

Replies have been disabled for this discussion.