Generate a random boolean in PHP
How to Generate Random Boolean Values in PHP
// PHP 4+
$randBool = (bool) mt_rand(0, 1);
Example 2
$value = rand(0,1) == 1;
// PHP 4+
$randBool = (bool) mt_rand(0, 1);
$value = rand(0,1) == 1;
In this page (written and validated by A. Gawali) you learned about . What's Next? If you are interested in completing PHP tutorial, we encourage you simply to start here: PHP Tutorial.
Share On: |