Variable function compatibility with PHP 7 and PHP5

Viewed 545

I have a situation where this works in PHP5 but fatals in PHP7:

/* load batch processing data into variable */
$args = get_option('leads_batch_processing');
/* process batches */
self::$args['method']($args);

And this works in PHP7 but fatals PHP5:

/* load batch processing data into variable */
$args = get_option('leads_batch_processing');
/* process batches */
 self::{$args['method']}($args);

How can I use the variable function successfully in both PHP environments? I tried using an if condition based on PHP version but the PHP7 version's syntax fatals PHP5 so I cannot go that route.

What do I do?

1 Answers
Related