Results 1 to 3 of 3

Thread: PHP version change, using anonymous functions

  1. #1
    Join Date
    Mar 2006
    Location
    Illinois, USA
    Posts
    12,164
    Thanks
    265
    Thanked 690 Times in 678 Posts

    Default PHP version change, using anonymous functions

    I have some old code that isn't working:
    PHP Code:
    function($str) { return '.'.$str; } 
    Context:
    PHP Code:
    array_map((function($str) { return '.'.$str; }),$array)) 
    My server is currently running PHP 5.2.17. The old one was probably version 4. I don't remember, and it's been a while.

    I can certainly work around this on my own, but I'm wondering if there's a proper/recommended method to fix this in general. It comes up once in a while.


    Edit: Ah. I must have gone BACK a version. It was probably 5.3 before, now 5.2, without anonymous functions. It looks like create_function() is my best option?
    I should get my host to update PHP I guess....
    Last edited by djr33; 02-21-2014 at 04:50 AM.
    Daniel - Freelance Web Design | <?php?> | <html>| espa˝ol | Deutsch | italiano | portuguŕs | catalÓ | un peu de franšais | some knowledge of several other languages: I can sometimes help translate here on DD | Linguistics Forum

  2. #2
    Join Date
    Apr 2008
    Location
    So.Cal
    Posts
    3,643
    Thanks
    63
    Thanked 516 Times in 502 Posts
    Blog Entries
    5

    Default

    create_function is your best bet, yes, but there are problematic things about it. I would definitely go with the upgrade-php-and-use-real-anonymous-functions approach.

  3. The Following User Says Thank You to traq For This Useful Post:

    djr33 (02-21-2014)

  4. #3
    Join Date
    Mar 2006
    Location
    Illinois, USA
    Posts
    12,164
    Thanks
    265
    Thanked 690 Times in 678 Posts

    Default

    Alright, I was able to update the version of PHP on the server. Resolved.

    Thanks-- I was also wondering about the best answer, so that works (if necessary).
    Daniel - Freelance Web Design | <?php?> | <html>| espa˝ol | Deutsch | italiano | portuguŕs | catalÓ | un peu de franšais | some knowledge of several other languages: I can sometimes help translate here on DD | Linguistics Forum

Similar Threads

  1. Anonymous Feild name and Table name
    By letom in forum MySQL and other databases
    Replies: 0
    Last Post: 03-14-2013, 03:14 PM
  2. Change functions array parameter
    By Vrmonk in forum JavaScript
    Replies: 0
    Last Post: 08-28-2012, 08:02 PM
  3. Staying anonymous with a proxy
    By division1 in forum The lounge
    Replies: 6
    Last Post: 03-14-2009, 06:58 PM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •