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
shogemuk
Forum Newbie
Posts: 4 Joined: Mon Aug 22, 2011 2:28 am
Post
by shogemuk » Mon Mar 05, 2012 3:21 am
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
requinix
Spammer :|
Posts: 6617 Joined: Wed Oct 15, 2008 2:35 am
Location: WA, USA
Post
by requinix » Mon Mar 05, 2012 3:45 am
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
Post
by shogemuk » Mon Mar 05, 2012 5:04 am
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.
requinix
Spammer :|
Posts: 6617 Joined: Wed Oct 15, 2008 2:35 am
Location: WA, USA
Post
by requinix » Mon Mar 05, 2012 2:16 pm
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?