Jump to content

Concatenating Class Variables?


altergothen

Recommended Posts

Variable Variables???

 

I am used to concatenating variables like this when doing procedural PHP like this ....

 

$i=5;

${"varnumber_$i"} = 'This variable should be called varnumber_5';

 

How do I make a variable variable in a PHP5 class ?

How do I achieve the following without resorting to Case Statements?

 

.... here is my event handler in my class :

 

public function handleAction( $i ){

$this->handleEvent_$i

}

 

public function handleEvent_1 () {

echo "Handling Event1";

}

 

public function handleEvent_2 () {

echo "Handling Event1";

}

public function handleEvent_3 () {

echo "Handling Event1";

}

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
×
×
  • Create New...