note 14105 added to function.call-user-func.php

From: Date: Tue, 17 Jul 2001 20:31:15 +0000
Subject: note 14105 added to function.call-user-func.php
Groups: php.notes 
Request: Send a blank email to php-notes+get-15497@lists.php.net to get a copy of this message
I was trying to call multiple functions within a class, and after a brain frying experience this is what came out... hope it helps: class Foo { function hey1($id){echo "In hey1";} function hey2($id){echo "In hey2";} #... and so forth ... function runtest($id) { #the fun part :) for($i=1; $i<=2; $i++) { $fp = "hey".$i; $this->$fp($id); } } } It worked like a charm :). http://www.php.net/manual/en/function.call-user-func.php

« previous php.notes (#15497) next »