﻿ PHP Exercises: Test if a given non-negative number is a multiple of 13 or it is one more than a multiple of 13 - w3resource

# PHP Exercises: Test if a given non-negative number is a multiple of 13 or it is one more than a multiple of 13

## PHP Basic Algorithm: Exercise-41 with Solution

Write a PHP program to test if a given non-negative number is a multiple of 13 or it is one more than a multiple of 13.

Sample Solution:

PHP Code :

``````<?php
function test(\$n)
{
return \$n % 13 == 0 || \$n % 13 == 1;
}

var_dump(test(13));
var_dump(test(14));
var_dump(test(27));
var_dump(test(41));
``````

Sample Output:

```bool(true)
bool(true)
bool(true)
bool(false)
```

Flowchart:

PHP Code Editor:

What is the difficulty level of this exercise?

﻿

## PHP: Tips of the Day

\$_REQUEST: This SuperGlobal Variable is used to collect data submitted by a HTML Form

Example:

This code save in a php file and run in the browser.

```<!DOCTYPE html>
<html>
<body>

<form method="post" action="<?php echo \$_SERVER['PHP_SELF'];?>">
NAME: <input type="text" name="user">
<button type="submit">SUBMIT</button>
</form>
<?php
if (\$_SERVER["REQUEST_METHOD"] == "POST") {
\$name = htmlspecialchars(\$_REQUEST['user']);
if(empty(\$name)){
echo "Name is empty";
} else {
echo \$name;
}
}
?>
</body>
</html>
```

Output:

```Owen
```