-1

There is a plugin which is trying to deactivate some of my PHP functions. Is there a way to add a rand to the function name?

This is what I'm trying to archieve:

$rand = rand(10,100);

function thisismyname . $rand() . () {
     function....
}
Joost de Valk
  • 49
  • 1
  • 5
  • 1
    Why do you even need that? That is not how functions are programmed. And also, $rand is not a function so the () are useless. – Koen Hollander Mar 16 '17 at 21:28
  • @KoenHollander I know, I was wondering if this is maybe possible. Some plugin is deactivating my functions, this way he cannot deactivate them, – Joost de Valk Mar 16 '17 at 21:29
  • I don''t think it is possible Joost. (Just a irrelevant question: We are both dutch?) – Koen Hollander Mar 16 '17 at 21:30
  • @KoenHollander Well, gonna find a different solution, then. (Irrelevant answer to irrelevant question: Yes, I'm Dutch indeed! Looking at your name, you're also Dutch). – Joost de Valk Mar 16 '17 at 21:32
  • Possible duplicate of [Use a variable to define a PHP function](http://stackoverflow.com/questions/7213825/use-a-variable-to-define-a-php-function) – Ivar Mar 16 '17 at 21:43
  • Some plugin is deactivating your functions? What plugin is that? – Jay Blanchard Mar 16 '17 at 21:44
  • @JayBlanchard With all respect, I don't think that's relevant to share. – Joost de Valk Mar 16 '17 at 21:46
  • 1
    I think it is absolutely relevant! Sounds like malware or virus-ware. I have never see a plugin that can deactivate functions in PHP. – Jay Blanchard Mar 16 '17 at 21:47
  • @JayBlanchard It's a semi-popular plugin which is trying to deactivate certain functions (which are containing ads) from our plugin. It's not anything like malwave, just some person which isn't satisfied with our ad placement. – Joost de Valk Mar 16 '17 at 21:50

1 Answers1

3

You could define a function into a variable with a rand name and then call it. Ex:

<?php
$function_name = mt_rand(100,10000); //rand name
$func_{$function_name} = function(){ 
    echo 'Your function';
}; //variable that contains the function, named with the rand value obtained 

echo "Name: func_$function_name() =>";
$func_{$function_name}(); //Execute function

This outputs:

Name: funct_6929() => Your function

With a diferent name in each run.

aperpen
  • 718
  • 7
  • 10