Php function return

Place for questions and answers for all newcomers and new coders. This is a free for all forum, no question is too stupid and to noob.
Post Reply
User avatar
hallsofvallhalla
Site Admin
Posts: 12026
Joined: Wed Apr 22, 2009 11:29 pm

Re: Pho function return

Post by hallsofvallhalla »

i am not sure what exactly you are going for here but to return a function in php

Code: Select all

$result = ResolveBattle($playerinfo3);

function ResolveBattle($playerinfo3)
{
$roll = $playerinfo3['attack'] + rand(1,20);
return $roll
}
$result will have the roll + the players attack


Hope that helps
User avatar
Jackolantern
Posts: 10891
Joined: Wed Jul 01, 2009 11:00 pm

Re: Pho function return

Post by Jackolantern »

I am a bit confused by this as well. You are talking about "on click" the function is called, but PHP doesn't work that way, but the code you posted is PHP code.
The indelible lord of tl;dr
User avatar
Jackolantern
Posts: 10891
Joined: Wed Jul 01, 2009 11:00 pm

Re: Php function return

Post by Jackolantern »

Oh, I gotcha! I thought you meant like a click event, such as in Javascript. :cool:
The indelible lord of tl;dr
Post Reply

Return to “Beginner Help and Support”