473,466 Members | 1,562 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

eregi

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
1 2011
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: fartsniff | last post by:
Hello all. I am starting to work on a URL "cleaner" of sorts. The code below is only checking for a few simple entries on the URL, but for some reason it is not replacing them with "" when...
1
by: Ralph Freshour | last post by:
Can someone please tell me why this function always evaluates to true regardless of what I enter? Thanks... if (!eregi ("A-Za-z", $frm_member_name)) { // invalid characters...
5
by: Jane Doe | last post by:
Hi I took a quick look in the archives, but didn't find an answer to this one. I'd like to display a list of HTML files in a directory, showing the author's name between brackets after the...
1
by: NimP | last post by:
Hi,. I'm trying to detect any links that are contained within an html page using eregi pattern matching. I was wondering if there are any pattern matching geniuses out there who could write a...
5
by: george | last post by:
(driving me nuts) Hi there. I wonder if anyone can help? I'm including a page from Google in search.php, passing some parameters. So far so good. Then I'm asking to look through that Google...
2
by: Frank | last post by:
I'm having trouble detecting whitespaces in strings. Set up this test: echo "<br>example 1:".intval(eregi("^\s","teststring")); echo "<br>example 2:".intval(eregi("^\s","test string")); ...
25
by: Dynamo | last post by:
Hi The following script was taken from John Coggeshall's (PHP consultant) in his article on Zends site at http://www.zend.com/zend/spotlight/ev12apr.php // Get the email address to validate...
1
by: news | last post by:
God, I have read every comment in php.net eregi and Google searched, and I have tried so many different attempts...this is the closest I've gotten to verify a variable contains only:...
4
by: Nel | last post by:
Hi all, I am struggling with understanding a small eregi problem in php4. My code: <?PHP $htmlsource = '<img src="pics/hotdog.gif"> text text <img src="pics/silly%20sausage.gif"> ';...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.