FRIHOST FORUMS SEARCH FAQ TOS BLOGS COMPETITIONS
You are invited to Log in or Register a free Frihost Account!


OOP





asiddle423
I have a test.php and a function.php

I want to be able to edit variables in the test.php to run certain functions in my function.php

I have seen an example such as this used before.

Code:

//if set to 1 use funtion
//if set to 0 dont use function
$function1 = 1;
$function2 = 1;
$function3 = 0;


can anyone help me with putting a code like this to use with classes please
jabapyth
how do you know what the function is for each?
eg.
Code:

function do()
{
   echo "Done";
}
function dont()
{
   echo "diddnt";
}
$function1=Array(1,do);
$function2=Array(0,dont);
$MyArray=Array($function1,$function2);
foreach($MyArray as $func)
{
   if ($func[0]==1)
   {
      $func[1]()  // execute the function
   }
}

Good Luck! Very Happy
asiddle423
its something i got like this

Code:
//set functions to load
$validate = 1; //on
$insertIntoDb = 1; //on
$sendEmail = 0; //off

//then a code similar to what you posted to execute the on functions
if($validate == 1)
{
     $function->validate();
}
if($insertIntoDb == 1)
{
     $function->insertIntoDb();
}
if($sendEmail == 1)
{
     $function->sendEmail();
}


how could this be changed so i don't have to create a new if statement each time so it saves time, file size and the amount of code that is in the script.
Related topics
More forum types.
Java
What computer languages you know?
C++ TUTORIAL : INTRODUCTION TO C++
utility of classes with php
Programming
PHP Editing Question
Programmation
YASI (Yet Another Self Introduction)
PHP OOP Tutorial
What lanugage should I learn next?
PHP OOP
OOP
Any one can help 4 PHP object coding self learning site?
having difficulties understanding OOP
Reply to topic    Frihost Forum Index -> Scripting -> Php and MySQL

FRIHOST HOME | FAQ | TOS | ABOUT US | CONTACT US | SITE MAP
© 2005-2011 Frihost, forums powered by phpBB.