Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Function : bcmod is not available

Tags:

php

I'm getting the following error while installing one of a joomla component.

Function : bcmod is not available. Please ask your hosts how you can enable this function in your PHP installation.

like image 414
Chillu Avatar asked May 16 '12 20:05

Chillu


2 Answers

you need your PHP to be compiled with bcmath support (--enable-bcmath configure option). If you're on shared hosting it is unlikely they will enable it for you. So you can try a solution from PHP manual from this page: http://ru.php.net/manual/en/function.bcmod.php I haven't tried it , but you can test it:

/** 
 * my_bcmod - get modulus (substitute for bcmod) 
 * string my_bcmod ( string left_operand, int modulus ) 
 * left_operand can be really big, but be carefull with modulus :( 
 * by Andrius Baranauskas and Laurynas Butkus :) Vilnius, Lithuania 
 **/ 
function my_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; 
} 

// example 
echo my_bcmod( "7044060001970316212900", 150 ); 
like image 188
Alexey Avatar answered Sep 26 '22 15:09

Alexey


If you have a dedicated server, try the solution given here https://stackoverflow.com/a/25229386/8015825.

Before recompiling, check the php.ini file and search for "bcmath". You may find bcmath.scale=0. If so, change the 0 to a 2.

And then restart your http server

like image 36
m50 Avatar answered Sep 24 '22 15:09

m50