0

I have a function called check_nickname() And I want to write something like this

$ttt='nickname';
check_.$ttt();

How can I do it correct ?

2
  • What do you want the function to actually do? What do you have so far? Commented Oct 21, 2011 at 14:08
  • I'll have several functions but will call them with a single line depending on the input Commented Oct 21, 2011 at 14:12

4 Answers 4

3

I would advise against that.

this will produce unmaintainable and undebuggable code.

I'd make one function which does all the verifications.

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

1 Comment

I think you are right. Despite the fact that this method will work I'll try to make one for all.
2

Create a variable that holds the function name, and apply parentheses to it:

$ttt='nickname';
$funcname = 'check_'.$ttt;
$funcname();

Comments

1

You would need to create another variable, such as $a = "check_".$ttt;, then call $a();

Comments

0
$ttt = 'nickname';
$your_function = 'check_' . $ttt;

$your_function();

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.