Other Software > Developer's Corner
[PHP] Confused with functions
(1/1)
RedPillow:
This has nothing to do with the thread I made few minutes ago.
Anyways ... I need help with these thing related to PHP-functions:
- How do I set what the function needs to work?
Like ...
--- Code: PHP ---function countNumbers() {echo ($x + $y);}
Now, how do I declare, that the function I made needs parameters $x and $y to count like so:
countNumber(1, 2);
Second question is, can function return multiple values, like with a loop?
--- Code: PHP ---function countNumbers() {$rtnval = $x + $y; for ($i = 0; $i <= 5; $i++) {return $rtnval;}}
Third is, can I use function directly to output something like so:
--- Code: PHP ---echo countNumbers();
or
--- Code: PHP ---$numbers = countNumbers();echo Numbers;
mouser:
RedPillow, although you can get answers to your questions -- i think you would find that getting a book (free ebook or normal book) on php would be extremely helpful to you -- in very important ways. I urge you to find one, it will be worth the effort to read it.
RedPillow:
Yeah ... there's sometimes just too much questions I need answer for.
I'll go check the nearest library!
Renegade:
Check here:
http://php.net/manual/en/functions.arguments.php
function fName($variable)
etc. etc.
Navigation
[0] Message Index
Go to full version