This is now a about your coolest PHP busy loop implementation.
I like this one most:
>> Marius (mm at co-operation dot de)
My solution providing usleep on a windows based os:
// Helper function
function getmicrotime(){
list($usec, $sec) = explode(' ',microtime());
return ((float)$usec + (float)$sec);
}
// usleep alias function for windows
function msleep($micro_seconds=0) {
$stop = getmicrotime() + ($miliseconds / 1000);
while (getmicrotime() <= $stop) {
// loop
}
return true;
}
Name:
Anonymous2012-12-21 14:23
I think this is also a GRAET SOLUTION, guys:
function usleepWindows($usec)
{
$start = gettimeofday();
I also have endless amounts of while(1) loops. PHP [s]programmers[/p] are able to implement a while(1) loop in everything.
Name:
Anonymous2012-12-21 14:27
If you wonder how to end execution of a function (as I did), it's that simple: return
function foo($a) {
if(!$a) return;
echo 'true';
// some other code
}
foo(true) will echo 'true', foo(false) won't echo anything (as return ends execution of the function. Of course, therefore there is no need for 'else' before 'echo').
Name:
Anonymous2012-12-21 14:29
Ok guys here something that I use and it works
<?php
case banner:
echo "content in banner\n";
echo "another content in banner\n";
break;
case header:
echo "content in header\n";
echo "another content in header\n";
break;
case other:
echo "content in other\n";
echo "another content in other\n";
break;
}
?>
Now I will explain what each script does.
first part the
<?php
switch($_GET['id'])
{
should be included or it won't work
default is default link, lets say if this is in index.php then when index.php is loaded default will be shown.
case banner: or case header: or case other: is what will be hidden until visitors click on link that will take them there, the value after case is going to be added after the name of the file, lets say case banner: is in index.php then case banner: and its contents will be in index.php?id=banner same for header and other cases. note that you always should put break; tag should be included.
Hope this helped you guys, I am sorry if i didn't explain it well but I tried my best.
Name:
Anonymous2012-12-21 14:36
Ultimate explanation to object references:
NOTE: wording 'points to' could be easily replaced with 'refers ' and is used loosly.
<?php
$a1 = new A(1); // $a1 == handle1-1 to A(1)
$a2 = $a1; // $a2 == handle1-2 to A(1) - assigned by value (copy)
$a3 = &$a1; // $a3 points to $a1 (handle1-1)
$a3 = null; // makes $a1==null, $a3 (still) points to $a1, $a2 == handle1-2 (same object instance A(1))
$a2 = null; // makes $a2 == null
$a1 = new A(2); //makes $a1 == handle2-1 to new object and $a3 (still) points to $a1 => handle2-1 (new object), so value of $a1 and $a3 is the new object and $a2 == null
//By reference:
$a4 = &new A(4); //$a4 points to handle4-1 to A(4)
$a5 = $a4; // $a5 == handle4-2 to A(4) (copy)
$a6 = &$a4; //$a6 points to (handle4-1), not to $a4 (reference to reference references the referenced object handle4-1 not the reference itself)
$a4 = &new A(40); // $a4 points to handle40-1, $a5 == handle4-2 and $a6 still points to handle4-1 to A(4)
$a6 = null; // sets handle4-1 to null; $a5 == handle4-2 = A(4); $a4 points to handle40-1; $a6 points to null
$a6 =&$a4; // $a6 points to handle40-1
$a7 = &$a6; //$a7 points to handle40-1
$a8 = &$a7; //$a8 points to handle40-1
$a5 = $a7; //$a5 == handle40-2 (copy)
$a6 = null; //makes handle40-1 null, all variables pointing to (hanlde40-1 ==null) are null, except ($a5 == handle40-2 = A(40))
?>
Hope this helps.
Name:
Anonymous2012-12-21 14:43
>>14
>>Hope this helps.
>>Hope this helps.
>>Hope this helps.
>>Hope this helps.
>>Hope this helps.
Name:
Anonymous2012-12-21 19:27
There are only two kinds of languages: the ones people complain about and the ones nobody uses.