Skip to content
This repository has been archived by the owner on Dec 4, 2018. It is now read-only.

PHP 5.5 Error: preg_replace() is deprecated #187

Open
DustyReagan opened this issue Dec 16, 2013 · 3 comments
Open

PHP 5.5 Error: preg_replace() is deprecated #187

DustyReagan opened this issue Dec 16, 2013 · 3 comments

Comments

@DustyReagan
Copy link
Contributor

I just updated our servers to PHP 5.5 and noticed we're getting a new error in EpiTwitter.php on line 81:

Error: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead

The line is: $endpoint = '/' . preg_replace('/[A-Z]|[0-9]+/e', "'/'.strtolower('\0')", $parts) . '.json';

I've not figured out how to rewrite the preg_replace function to avoid this error as of yet.

@jmathai
Copy link
Owner

jmathai commented Dec 16, 2013

Thanks. From the docs it looks like they suggest using preg_replace_callback.

http://www.php.net/manual/en/migration55.deprecated.php

The preg_replace() /e modifier is now deprecated. Instead, use the preg_replace_callback() function.

@benlongstaff
Copy link

changing
$endpoint = '/'.preg_replace('/[A-Z]|[0-9]+/e', "'/'.strtolower('\0')", $parts).'.json';
to
$endpoint = '/'. preg_replace_callback('/[A-Z]|[0-9]+/', function($m){ return strtolower($m[0]);}, $parts).'.json';
fixes it

@DustyReagan
Copy link
Contributor Author

@benlongstaff Looks like it's missing a '/' Try it on $Twitter->get_accountVerify_credentials() to see.

I think this fixes it:

$endpoint = '/'. preg_replace_callback('/[A-Z]|[0-9]+/', function($m){ return '/' . strtolower($m[0]);}, $parts).'.json';

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants