-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....
}
9
  • 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. Commented Mar 16, 2017 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, Commented Mar 16, 2017 at 21:29
  • I don''t think it is possible Joost. (Just a irrelevant question: We are both dutch?) Commented Mar 16, 2017 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). Commented Mar 16, 2017 at 21:32
  • 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. Commented Mar 16, 2017 at 21:47

1 Answer 1

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.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.