altergothen Posted January 22, 2009 Report Share Posted January 22, 2009 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"; } Quote Link to comment Share on other sites More sharing options...
monkeysaurus Posted January 23, 2009 Report Share Posted January 23, 2009 Now, this is just an observation, but... In the code above, each of your echo statements reads "Handling Event1". You have changed that in the actual code? What error message are you getting? Quote Link to comment Share on other sites More sharing options...
Recommended Posts
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.