August 30, 2013
Override if condition fulfills in sleep() function in php
MR.Test’s Question:
Is it possible to write sleep function with condition in php?
Example…
Public function sleepy() {
sleep(100);
If(condition a) {
Sleep(50);
} else {
Echo 'some thing'
}
}
So that the sleep(50) must be override the 100 if condition full fill?
How could I achieve similar concept, in proper programming practice?
By the way, I am typing from my iphone, sorry for any unclear code, if any…
If that is only thing you are trying to do, then just move the the sleep(100)
inside the else portion.
public function sleepy() {
if(condition a) {
sleep(50);
} else {
sleep(100);
echo 'some thing'
}
}
If you are really trying to override the parameter like that, you can design you own function to execute the sleep afterward instead.