Ratings | | Unique User Downloads | | Download Rankings |
Not yet rated by the users | | Total: 28 | | All time: 11,176 This week: 206 |
Version | | License | | PHP version | | Categories |
m5 1.0 | | Custom (specified... | | 5 | | PHP 5, Language |
|
Description | | Author |
This class can call a handler if an event action returns true.
It takes a function to be called and evaluate if it returns true.
Another given function will be called in the first returned true. | |
|
|
Innovation award
Nominee: 23x
Winner: 2x |
|
Example
<?php
require_once('./conditionalEvent.class.php');
function test(){
echo 'you are the happy winner of the day call +00220022155418 to claim your gift ';
return true;
}
function sumit($x,$y,$z){
return $x+$y+$z;
}
/* ici on envoie la liste des param?tres de la fonction ?
appliquer dans l'ordre o? ils sont d?clar?s et m?me lorsque la fonction n'a qu'un seul param?tre
on doit dans tous les cas utiliser un array sauf ?videmment si la function n'exige aucun
param?tre pour fonctionner comme dans l'exemple num?ro 1...
here we send the list of function's parameters in an array
in the same order they have been declared in the function's declaration...Even if it's a single parameter
we must anyway use the array to send this parameter except if the function doesn't need any parameter
to work just like in the first example...
*/
echo'<pre>';
$exemple=new conditionalEvent('test','sumit',5);
var_dump ($exemple);
var_dump($exemple->eventapply(array(1,2,3)));
function test2($x,$y,$z){
echo 'you are the happy winner ';
return $x+$y+$z;
}
function sumit2($x,$y,$z){
return $x+$y+$z;
}
$exemple2=new conditionalEvent('test2','sumit2',6,array(1,2,3));
var_dump ($exemple2);
var_dump($exemple2->eventapply(array(1,2,3)));
?><br>must use one filelog by event.Its for this reason that it would be clever to use database instead of simple
file system
|
Details
ConditionalEvent class is a really simple way to make one of your PHP apps
users to launch a predefined number of times a predefined action when a predefined condition is
respected when they come on your website.
For example;imagine that you want to tell the 5 first users who connect to your website and respect
the predefined condition that they are women that they, each one,are the happy winner of the gift of day.All
you have to do is to add this little script where you want action to be lauched and all is done...
The class use a file log to control if action needs to be launched.
A suggestion is to replace this part of the script by a
database's field control and update.
Other major amelioration is to use Ajax , to bring user to launch action...
public function __construct($condition,$function,$z=0,$x=array())
$condition must be a string type , it's the name of the first function.This function returned value must be evaluate
by PHP as true for launching $function which is the name of type string which represent the action which must be launched.
$z represent the number of times the predefined action must be launched.by default $z equals 0.That means infinite
number of times.$x is an array which contains the condition's parameters in the same order that they have been declared
in function's declaration
public function eventapply($y=array())
$y is an array which contains the action to be launched parameters in the same order that they have been declared
in function's declaration
The script is too short to provide a documentation but you can see
a how to use example in the testconditionalEvent.php file.
Bug reporting to leizmo@gmail.com or simply use the
dedicated forums to ask your questions...
|
Applications that use this package |
|
No pages of applications that use this class were specified.
If you know an application of this package, send a message to the author to add a link here.