|
Posted by Schraalhans Keukenmeester on 06/02/07 16:15
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"); }
> [/code]
>
> 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 - schraalhans@the.Spamtrapexample.nl
[Remove the lowercase part of Spamtrap to send me a message]
"strcmp('apples','oranges') < 0"
Navigation:
[Reply to this message]
|