debug - PHP Online
Form of PHP Sandbox
Enter Your PHP code here for testing/debugging in the Online PHP Sandbox. As in the usual PHP files, you can also add HTML, but do not forget to add the tag <?php
in the places where the PHP script should be executed.
Result of php executing
Full code of debug.php
- <!DOCTYPE html>
- <html>
- <body>
- <?php
- function computeCheckDigit($identificationNumber) {
- for ($i; $i <= strlen($identificationNumber); $i++) {
- if ($i % 2 == 0) {
- $sum += $identificationNumber{$i};
- }
- }
- $sum *= 3;
- for ($i; $i <= strlen($identificationNumber); $i++) {
- if ($i % 2 != 0) {
- $sum += $identificationNumber{$i};
- }
- }
- $array = str_split($sum);
- $lastDigit = end($sum);
- $result = 10 - $lastDigit;
- return $result;
- }
- echo computeCheckDigit('39847');
- //expected 7
- ?>
- </body>
- </html>