Howdy! Can someone explain to me what function eregi_replace is performing in the code below and how to replace it with maybe str_replace or preg_replace?
public function __construct($options)
To your question: yes.
Slightly beside the side note: I know exceptional (PHP) programmers who continue to use deprecated features for a wide variety of reasons. There isn’t a whole lot hugely wrong with POSIX regular expressions (though it has issues, just like PCRE) and I certainly wouldn’t label it “crap”. Whichever view point you take, at least you’re learning new (not so “crap”) ways of doing things rather than simply accepting what’s given to you on the plate. (:
dirname( $_SERVER['PHP_SELF'] ) Would also work as long as PHP_SELF always contained a file.
Thanks for your help. I guess my frustration with this tutorial is really showing. At first it looked so promising and then it just died with the guy leaving a download link to the source. From now on I’ll be checking in with the final post on tutorials.
The intention was to remove the text “/index.php” from the URL in $_SERVER[‘PHP_SELF’]. It will actually delete any string of the form “/index<any single character that is not a newline>php” but that’s probably just a mistake on their part (as is using regex for this task in the first place).
The equivalent str_replace would be very similar: str_replace(‘/index.php’, ‘’, $_SERVER[‘PHP_SELF’])
Using preg_replace is not necessary since there is no need here to look for any pattern, just a plain string.
So your saying that this would be the way to fix this code?
On a side note: This program was written on Dec of last year and for a tutorial. I don’t understand why programmers that build themselves up to be so good, include deprecated code in their tutorials. It’s so frustrating and actually disheartening to spend time on a tutorial to find it has crap for code in it. Okay I’m finished.