echorand(1,10); // Random integer between 1 and 10echomt_rand(1,10); // Faster random integer between 1 and 10echolcg_value(); // Random float between 0 and 1
$a =5; // 101 in binary$b =3; // 011 in binaryecho $a & $b; // Bitwise AND: 1 (001 in binary)echo $a | $b; // Bitwise OR: 7 (111 in binary)echo $a ^ $b; // Bitwise XOR: 6 (110 in binary)echo~$a; // Bitwise NOT: -6echo $a <<1; // Left shift: 10 (1010 in binary)echo $a >>1; // Right shift: 2 (10 in binary)
These scalar operations form the foundation for more complex calculations in PHP, particularly in the context of mathematical and machine learning applications. They can be used to manipulate individual values, perform element-wise operations on arrays, and implement various algorithms.