Do you have a question? Post it now! No Registration Necessary.  Now with pictures!

Threaded View
Hi, (new to group and a php novice)

I'm editing some files using exapmles for reference.

(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.
(Invalid return address, please reply to newsgroup).

Re: eregi

At Sat, 02 Jun 2007 10:58:13 +0100, fade2gray let h(is|er) monkeys type:

Quoted text here. Click to load it

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


Schraalhans Keukenmeester -
[Remove the lowercase part of Spamtrap to send me a message]

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

Site Timeline