Closed the247er closed 8 years ago
I've got this issue as well, I would appericiate if this method could be added to this library to prevent issues when using this on a version of PHP where this method doesn't exist. However, thank you for this example, I am going to try this!
resolved in https://github.com/jschaedl/Iban/pull/18 but not merged yet
As far as I can see it, this issue is not resolved in https://github.com/jschaedl/Iban/pull/18 There is no fallback bcmod function included yet. Maybe @bobmulder can do it and make a new pull request?
@jschaedl I could add the bcmod-method if you want?
do it
Where should I put the code? I did it in my own config-file...
The code you need:
/**
* Function bcmod (for IBAN library)
*/
if (!function_exists('bcmod')) {
function bcmod($x, $y)
{
$take = 5;
$mod = '';
do {
$a = (int)$mod . substr($x, 0, $take);
$x = substr($x, $take);
$mod = $a % $y;
} while (strlen($x));
return (int)$mod;
}
}
@bobmulder: Thank you for providing. I added the fallback method to https://github.com/jschaedl/Iban/blob/master/library/IBAN/Core/IBAN.php
Great @jschaedl. Guess this issue could be closed?
Exactly.
in ban/library/IBAN/Core/IBAN.php on line 115 you use the code
return bcmod($invertedIban, 97) === '1';
bcmod is (even in php 5.*) not always available since the Math extention should be configureda fix could be including a fallback bcmod function
if ( !function_exists('bcmod') ){ function bcmod( $x, $y ) { // how many numbers to take at once? carefull not to exceed (int) $take = 5; $mod = ''; do { $a = (int)$mod.substr( $x, 0, $take ); $x = substr( $x, $take ); $mod = $a % $y; } while ( strlen($x) ); return (int)$mod; } }