Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 3937424
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 20, 20262026-05-20T00:04:01+00:00 2026-05-20T00:04:01+00:00

What is wrong with my code? I ran the code on my test server

  • 0

What is wrong with my code? I ran the code on my test server and the code worked but when I upload it to my production server I get

Parse error: syntax error, unexpected T_FUNCTION in /hermes/bosweb/web013/b130/ipg.acrsflcom/darayngedbeats/gentest.php on line 10

here is my code

$old = "http://darayngedbeats1.s3.amazonaws.com    /mp3/CrazyMonsta2.mp3?AWSAccessKeyId=AKIAJXA36ESCLQHCB54Q&Expires=1297279906& Signature=HD36ZQE8yeTIW6JPWKMcciPTiTs%3D"; //enter the key that needs to be converted
$search =  array(":","?","=","&","%");
$replace = array("%3A","%3F","%3D","%26","%25");

function search_replace($s,$r,$sql)
{ $e = '/('.implode('|',array_map('preg_quote', $s)).')/';
  $r = array_combine($s,$r);
  return preg_replace_callback($e, function($v) use ($s,$r) { return $r[$v[1]];  },$sql);
}

echo "<br><br>";
$new = search_replace($search,$replace,$old);
echo $new;

?>
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-20T00:04:02+00:00Added an answer on May 20, 2026 at 12:04 am

    The error is likely caused by

    return preg_replace_callback($e, function($v) use ($s,$r) { return $r[$v[1]];  },$sql);
    

    Chances are you’re using PHP 5.2 or earlier, which doesn’t support closures. You can find out which version of PHP you’re using phpinfo().

    You’ll likely either need to upgrade to PHP 5.3+, or use create_function, or write a static function and pass it as a callback.

    Here’s an example of the last option, using a simple class to store the state of $r:

    class My_callback {
      public function __construct($s, $r) {
        $this->s = $s; $this->r = $r;
      } 
    
      function callback($v) { return $this->r[$v[1]]; }
    }
    
    function search_replace($s,$r,$sql) {
      $e = '/('.implode('|',array_map('preg_quote', $s)).')/';
      $r = array_combine($s,$r);
      $c = new My_callback($s, $r);
      return preg_replace_callback($e, array($c, 'callback'), $sql);
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Whats wrong with the following c# code? Compiler reports this error: Inconsistent accessibility: parameter
I have problem compilin this code..can anyone tell whats wrong with the syntax CREATE
I'm trying to use the following code but it's returning the wrong day of
Can someone tell me what's wrong with this code? I'm trying to upload a
This code is throwing the following error in IE, but not in any other
There's something wrong with my code or I'm just not understanding this fully. I
This snippet of Perl code in my program is giving the wrong result. $condition
I work on relatively sensitive code that we wouldn't want falling into the wrong
Today someone asked me what was wrong with their source code. It was obvious.
What did I do wrong? Here is an excerpt from my code: public void

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.