+ Reply to Thread
Page 1 of 2 12 LastLast
Results 1 to 10 of 11
Like Tree3Likes

Thread: PHP 5.3 Help

  1. #1
    dannyb0986 is offline x10Hosting Member dannyb0986 is an unknown quantity at this point
    Join Date
    May 2011
    Posts
    29

    Exclamation PHP 5.3 Help

    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!

  2. #2
    descalzo's Avatar
    descalzo is offline Grim Squeaker descalzo has a brilliant futuredescalzo has a brilliant futuredescalzo has a brilliant future
    Join Date
    Jul 2009
    Location
    Ankh-Morpork
    Posts
    7,636

    Re: PHP 5.3 Help

    Put:

    error_reporting(E_ALL & ~E_DEPRECATED);

    at the top of the script. That should stop the "deprecated" warnings.
    Nothing is always absolutely so.

  3. #3
    dannyb0986 is offline x10Hosting Member dannyb0986 is an unknown quantity at this point
    Join Date
    May 2011
    Posts
    29

    Re: PHP 5.3 Help

    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

  4. #4
    misson is offline x10 Spammer misson is a jewel in the rough
    Join Date
    Mar 2008
    Location
    Libertatia
    Posts
    2,506

    Re: PHP 5.3 Help

    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 by misson; 08-04-2011 at 03:32 AM.
    Be sure to read all pages linked in this post; they have further information that should prove useful. When asking for help, make sure you follow Eric Raymond's and Jon Skeet's guidelines for prompt, accurate responses. Please answer any questions I ask; they're not rhetorical (probably). Any posted code is intended as illustrative example, rather than a solution to your problem to be copied without alteration. Study it to learn how to write your own solution.
    Misson, not Mission.

  5. #5
    lllllllbob61 is offline x10Hosting Member lllllllbob61 is an unknown quantity at this point
    Join Date
    Jun 2011
    Location
    USA
    Posts
    9

    Re: PHP 5.3 Help

    Quote Originally Posted by descalzo View Post
    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.)

  6. #6
    callumacrae's Avatar
    callumacrae is offline not alex mac callumacrae is just really nice
    Join Date
    Dec 2007
    Location
    Wellesbourne, England
    Posts
    5,162

    Re: PHP 5.3 Help

    Quote Originally Posted by lllllllbob61 View Post
    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 by callumacrae; 08-08-2011 at 01:11 PM.
    dinomirt96 and karimirt47 like this.
    I can customise your phpBB board. Send me a PM.
    lynxphp - info, tutorials and scripts
    "A forum post should be like a skirt; long enough to cover the subject but short enough to keep things interesting."

  7. #7
    descalzo's Avatar
    descalzo is offline Grim Squeaker descalzo has a brilliant futuredescalzo has a brilliant futuredescalzo has a brilliant future
    Join Date
    Jul 2009
    Location
    Ankh-Morpork
    Posts
    7,636

    Re: PHP 5.3 Help

    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.
    Nothing is always absolutely so.

  8. #8
    callumacrae's Avatar
    callumacrae is offline not alex mac callumacrae is just really nice
    Join Date
    Dec 2007
    Location
    Wellesbourne, England
    Posts
    5,162

    Re: PHP 5.3 Help

    Quote Originally Posted by descalzo View Post
    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.


    Quote Originally Posted by descalzo View Post
    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
    I can customise your phpBB board. Send me a PM.
    lynxphp - info, tutorials and scripts
    "A forum post should be like a skirt; long enough to cover the subject but short enough to keep things interesting."

  9. #9
    misson is offline x10 Spammer misson is a jewel in the rough
    Join Date
    Mar 2008
    Location
    Libertatia
    Posts
    2,506

    Re: PHP 5.3 Help

    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.
    Be sure to read all pages linked in this post; they have further information that should prove useful. When asking for help, make sure you follow Eric Raymond's and Jon Skeet's guidelines for prompt, accurate responses. Please answer any questions I ask; they're not rhetorical (probably). Any posted code is intended as illustrative example, rather than a solution to your problem to be copied without alteration. Study it to learn how to write your own solution.
    Misson, not Mission.

  10. #10
    bdistler's Avatar
    bdistler is offline x10 Lieutenant bdistler is an unknown quantity at this point
    Join Date
    May 2010
    Location
    Catalina AZ USA
    Posts
    349

    Re: PHP 5.3 Help

    Quote Originally Posted by callumacrae View Post
    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'

+ Reply to Thread
Page 1 of 2 12 LastLast

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
x10hosting free hosting for the masses
dedicated servers