ok. Lets say I've got a certain function. It's named function1()...
I've seen a script that allows the user to create an action that the function does, when putting in something like function1(4) does what 4 is specified to, and function1(7) does what 7 is specified to do...
How would I go about making something like that?
Need more info? just ask--
function functions :/
Moderator: General Moderators
Many ways to do it, heres one:
etc. You can also call other functions inside one function and again call another function inside that function....
check http://www.php.net/manual/en/control-st ... switch.php
for more
-9902468
Code: Select all
function1($what_u_want){
switch ($what_u_want) {
case 0:
/* Code here */
case 1:
/* Code here */
}
}etc. You can also call other functions inside one function and again call another function inside that function....
check http://www.php.net/manual/en/control-st ... switch.php
for more
-9902468
Code: Select all
<?
function haha($waht) {
switch($waht) {
case 1:
echo "haha, foo<p>";
case 2:
echo "you tried to do 2 times! :/ <p>";
case hahahehe:
echo "you entered the hehehaha zone!<p>";
}
}
haha(1);
haha(1);
haha(2);
haha(hahahehe);
haha(1);
?>Why........?
- protokol
- Forum Contributor
- Posts: 353
- Joined: Fri Jun 21, 2002 7:00 pm
- Location: Cleveland, OH
- Contact:
You forgot to put break; statements in.
Code: Select all
function haha($waht) {
switch($waht) {
case 1:
echo "haha, foo<p>";
break; // need this
case 2:
echo "you tried to do 2 times! :/ <p>";
break; // need this
case hahahehe:
echo "you entered the hehehaha zone!
break; // need this<p>";
}
}