PHP 5.3 Help

dannyb0986

New Member
Messages
29
Reaction score
0
Points
0
Well since x10 upgraded, im starting to get some errors. It says this: Deprecated: Function eregi() is deprecated in ********** on line *** (in the stars there is info that i dont want to show). Here are the two codes that I am using that use eregi: // Find a match
if (eregi($Match, $agent)) {
break;
} else {

And the next one:

function makeActiveLink($originalString){

$newString = ereg_replace("[[:alpha:]]+://[^<>[:space:]]+[[:alnum:]/]","<a href=\"\\0\" target=\"_blank\">\\0</a>", $originalString);
return $newString;
}

Can anybody edit these, so that way they will work with PHP 5.3?

Thanks!
 

descalzo

Grim Squeaker
Community Support
Messages
9,373
Reaction score
326
Points
83
Put:

error_reporting(E_ALL & ~E_DEPRECATED);

at the top of the script. That should stop the "deprecated" warnings.
 

dannyb0986

New Member
Messages
29
Reaction score
0
Points
0
it still didnt work. Also i actually wanna fix the script, not hide the warnings

---------- Post added at 04:25 PM ---------- Previous post was at 04:24 PM ----------

Actually it did work. but still, just to be safe
 

misson

Community Paragon
Community Support
Messages
2,572
Reaction score
72
Points
48
The POSIX regular expression functions, such as eregi, should be replaced with the PCRE ones, such as preg_match. The PHP manual outlines the differences between POSIX and PCRE regexes and how you can convert, such as using the "i" modifier for case insensitive matching.

When posting code samples on X10, you can use
PHP:
, [html] or [code] tags (as appropriate) to delineate and format code. The [php] and [html] tags will cause the code to be colorized.
 
Last edited:

lllllllbob61

New Member
Messages
9
Reaction score
0
Points
0
Put:
error_reporting(E_ALL & ~E_DEPRECATED);
at the top of the script. That should stop the "deprecated" warnings.

Thanks.. I was just getting that error.. the error reporting fixed it. :)
Must have just upgraded the php.

I also was getting Undefined Index error.. from using this: $page = $_GET['page'];
Fix that with: if (isset($_GET['page'])) { $page = $_GET['page']; }
(I should have had it like that anyway I'm sure.)
 

callumacrae

not alex mac
Community Support
Messages
5,257
Reaction score
97
Points
48
Thanks.. I was just getting that error.. the error reporting fixed it. :)
Must have just upgraded the php.

I also was getting Undefined Index error.. from using this: $page = $_GET['page'];
Fix that with: if (isset($_GET['page'])) { $page = $_GET['page']; }
(I should have had it like that anyway I'm sure.)

Do not just hide the errors - fix the issue (read misson's post).
 
Last edited:

descalzo

Grim Squeaker
Community Support
Messages
9,373
Reaction score
326
Points
83
1. They are not errors. They are deprecated features. They still run.

2. If you have a third party script, good luck going through the entire batch of files to find each and every use of ereg_XXX and then changing them over to preg_YYYY . Especially when you can just add one line and have it run like it ran under 5.2.
 

callumacrae

not alex mac
Community Support
Messages
5,257
Reaction score
97
Points
48
1. They are not errors. They are deprecated features. They still run.

I haven't heard logic that bad for a very long time. Sure, they still run, but who know what will be happening in a couple major versions? Most likely, the function will have been removed entirely.


2. If you have a third party script, good luck going through the entire batch of files to find each and every use of ereg_XXX and then changing them over to preg_YYYY . Especially when you can just add one line and have it run like it ran under 5.2.

...we're talking about regex functions here, so I am assuming you have heard of regex? C'mon.

~Callum
 

misson

Community Paragon
Community Support
Messages
2,572
Reaction score
72
Points
48
If the third party package is still in development, the best thing to do is file a bug report and let the package developers sort it out. Turning off deprecated warnings will take care of things in the short term, until a new version of the package is released. If you're really kind, you can include a patch. A recursive grep at the command line will easily find all the calls to egrep_ functions, though switching to PCRE may not be trivial.

If the third party package is no longer under development, the use of the POSIX regex extension suggests it's been awhile since the package has been updated. The best course is to find a different package with similar functionality. Otherwise, it's up to the package user to update it.

Deprecated now means likely phased out in the future, and it's time to get a fix in place before that happens.
 

bdistler

Well-Known Member
Prime Account
Messages
3,534
Reaction score
196
Points
63
I haven't heard logic that bad for a very long time. Sure, they still run, but who know what will be happening in a couple major versions? Most likely, the function will have been removed entirely.

the 'logic' is to get the current version to run
if or when the user installs a newer version
where that 'fix' will not needed
it will not be in the code

with the condescending tone of your post
I understand you can not see the 'logic'
 

misson

Community Paragon
Community Support
Messages
2,572
Reaction score
72
Points
48
There seems to be less of an issue than warrants the tone this thread is developing. I'm sure everyone can agree that disabling the warnings is only a short-term measure (even though it wasn't initially presented as such), giving whoever is responsible for the code the time to fix it properly, after which deprecation warnings can be re-enabled. The deprecation message has done its job; the OP is now aware of the problem.
 
Top