What is the correct syntax to check for divisibility in PHP?
To check for divisibility in PHP, you can use the modulo operator (%), which returns the remainder of a division operation. If the remainder is 0, then the number is divisible by the divisor. You can use an if statement to check if the remainder is equal to 0 and then perform the desired action.
// Check if a number is divisible by another number
$number = 10;
$divisor = 2;
if ($number % $divisor == 0) {
echo "$number is divisible by $divisor";
} else {
echo "$number is not divisible by $divisor";
}