Change Function name in a loop

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
shogemuk
Forum Newbie
Posts: 4
Joined: Mon Aug 22, 2011 2:28 am

Change Function name in a loop

Post by shogemuk »

Hi Guys,
Does any know how to add a variable value to the name of the following function in a loop

Code: Select all

$i=1;
while($qryRowName = mysql_fetch_assoc($qryName)){
$i++;
function createTemplatedSlide$i(PHPPowerPoint $objPHPPowerPoint)
{
   // Create slide
   $slide = $objPHPPowerPoint->createSlide();

   // Add background image
    $slide->createDrawingShape()
          ->setName('Background')
          ->setDescription('Background')
          ->setPath('./images/realdolmen_bg.jpg')
          ->setWidth(950)
          ->setHeight(720)
          ->setOffsetX(0)
          ->setOffsetY(0);

    // Add logo
    $slide->createDrawingShape()
          ->setName('PHPPowerPoint logo')
          ->setDescription('PHPPowerPoint logo')
          ->setPath('./images/phppowerpoint_logo.gif')
          ->setHeight(40)
          ->setOffsetX(10)
          ->setOffsetY(720 - 10 - 40);

    // Return slide
    return $slide;
}
}
Thanks in advance
User avatar
requinix
Spammer :|
Posts: 6617
Joined: Wed Oct 15, 2008 2:35 am
Location: WA, USA

Re: Change Function name in a loop

Post by requinix »

Don't define the function in the loop. Leave it outside where it belongs.
shogemuk
Forum Newbie
Posts: 4
Joined: Mon Aug 22, 2011 2:28 am

Re: Change Function name in a loop

Post by shogemuk »

thanks for the reply tasairis,
I need to be able to create this function dynamically in a loop in order to change the values within in.
User avatar
requinix
Spammer :|
Posts: 6617
Joined: Wed Oct 15, 2008 2:35 am
Location: WA, USA

Re: Change Function name in a loop

Post by requinix »

shogemuk wrote:I need to be able to create this function dynamically in a loop in order to change the values within in.
No, you don't. Whatever you're talking about does not require defining multiple functions like that.

Care to explain more about what you're trying to do?
Post Reply