Found 1060 Articles for PHP

PHP – How to get the modulus of an arbitrary precision number using bcmod() function?

Urmila Samariya
Updated on 21-Aug-2021 07:27:15

299 Views

In PHP, bcmod() math function is used to calculate the modulus of an arbitrary precision number. The bcmod() function takes an arbitrary precision number as strings and it gives the result as a modulus of numbers after scaling the result to an identified precision. Or, we can say that it gets the remainder after dividing string_num1 by string_num2. Unless the string_num2 is 0, the result has the same sign as string_num1.Syntaxbcmod(string_$num1, string_$num2, [, int $scale=0])Or, bcmod(string $dividend, string $divisor[, int $scale=0])Note− The above syntax will get the remainder of dividing $string_num1 by $string_num2. Unless string_num2 is 0, the result has ... Read More

PHP – How to multiply two arbitrary precision numbers using bcmul() function?

Urmila Samariya
Updated on 21-Aug-2021 07:24:52

1K+ Views

In PHP, bcmul() math function is used to multiply one arbitrary precision number with another number. The bcmul() function takes two arbitrary precision numbers as strings and it gives the result as the multiplication of two numbers after scaling the result to an identified precision.Syntaxstring bcmul( $num_string1, $num_string2, $scaleVal)ParametersThe bcmul() math function accepts three different parameters $num_string1, $num_string2 and $scaleVal.$num_string1 - It represents the left operand and it is the string type parameter.$num_string2 - It represents the right operand, it is the string type parameter.$scaleVal - This is the optional integer type parameter that is used to set the number of digits ... Read More

PHP – How to raise an arbitrary precision number to another using bcpow() function?

Urmila Samariya
Updated on 21-Aug-2021 07:21:51

197 Views

In PHP, bcpow() function is used to raise an arbitrary precision base number to another exponent number. It takes two arbitrary precision numbers as strings and gives the base number raised to the power exponent after scaling the result to the listed precision.SyntaxString bcpow($base, $exponent, $scale)ParametersThe bcpow() function in PHP takes three different parameters: $base, $exponent and $scale.$base - It represents the base in which power will be raised and it is the string type parameter.$exponent - It represents the exponent and it is the string type parameter.$scale - It indicates the number of digits that appear after the decimal in ... Read More

PHP – How to add two arbitrary precision numbers using bcadd() function?

Urmila Samariya
Updated on 21-Aug-2021 07:20:13

442 Views

In PHP, bcadd() math function is used to add two arbitrary precision numbers. The bcadd() function takes two random precision numbers as strings and it returns the addition of the two numbers after scaling the result to an identified precision.Syntaxstring bcadd ( $num_str1, $num_str2, $scaleVal)ParametersThe bcadd() math function accepts three different parameters, $num_str1, $num_str2 and $scaleVal.$num_str1 - It represents the left operand and it is the string type parameter.$num_str2 - It represents the right operand and it is the string type parameter.$scaleVal - It is the optional parameter that is used to set the number of digits after the decimal place in the ... Read More

How to get an affine transformation matrix in PHP using imageaffinematrixget()?

Urmila Samariya
Updated on 09-Aug-2021 13:59:29

190 Views

imageaffinematrixget() is an inbuilt function in PHP that is used to get an affine transformation matrix. This function is often used in linear algebra and computer graphics.Syntaxarray imageaffinematrixget(int $type, mixed $options)Parametersimageaffinematrixget() accepts only two parameters: $type and $options.$type − The $type parameter specifies the integer to IMG_AFFINE constants.IMG_AFFINE_TRANSLATEIMG_AFFINE_SCALEIMG_AFFINE_ROTATEIMG_AFFINE_SHEAR_HORIZONTALIMG_AFFINE_SHEAR_VERTICAL$options − If type is IMG_AFFINE_TRANSLATE or IMG_AFFINE_SCALE, options has to be an array with keys x and y, both having float values. If type is IMG_AFFINE_ROTATE, IMG_AFFINE_SHEAR_HORIZONTAL or IMG_AFFINE_SHEAR_VERTICAL, options has to be a float specifying the angle.Return ValuesIt returns an affine transformation matrix, an array with keys from 0 to 5 ... Read More

How to check antialias functions be used or not by using imageantialias() function in PHP?

Urmila Samariya
Updated on 09-Aug-2021 13:56:12

144 Views

imageantialias() is an inbuilt function in PHP that is used to check whether antialias function is used or not. It activates the fast drawing anti-aliased methods for lines and wired polygons. It works only with true-color images and it doesn't support alpha components.Syntaxbool imageantialias($image, $enabled)Parametersimageantialias() takes two parameters: $image and $enabled.$image − The $image parameter is a GdImage object and an image resource that is returned by the image creation function imagecreatetruecolor.$enabled − The $enabled parameter is used to check whether antialiasing is enabled or notReturn Valuesimageantialias() returns True on success and False on failure.Example 1OutputRead More

How to apply a 3×3 convolution matrix using imageconvolution() in PHP?

Urmila Samariya
Updated on 09-Aug-2021 13:52:32

250 Views

imageconvolution() is an inbuilt function in PHP that is used to apply a 3×3 convolution matrix, using the coefficient and offset in the image.Syntaxbool imageconvolution ( $image, $matrix, $div, $offset)Parametersimageconvolution() takes four parameters: $image, $matrix, $div, and $offset.$image − This parameter is used to create the size of the image by using an image creation function such as imagecreatetruecolor().$matrix − This parameter contains an array of 3×3 matrix of floats.$div − It is used for normalization.$offset − This parameter is used to set the color offset.Return Valuesimageconvolution() returns True on success and False on failure.Example 1OutputInput PNG image before using ... Read More

How to apply a gamma correction to a Graphics Draw (GD) image in PHP?

Urmila Samariya
Updated on 09-Aug-2021 13:48:58

202 Views

imagegammacorrect() is an inbuilt function in PHP that is used to apply a gamma correction to a given Graphics Draw (GD) input image and an output gamma.Syntaxbool imagegammacorrect(resource $image, float $inputgamma, float $outputgamma)Parametersimagegammacorrect() takes three different parameters: $image, $inputgamma and $outputgamma.$image − Specifies the image to be worked.$inputgamma − Specifies the input gamma.$outputgamma − Specifies the output gamma.Return Valuesimagegammacorrect() returns True on success and False on failure.Example 1OutputInput image before using imagegammacorrect() PHP functionOutput image after using imagegammacorrect() PHP functionExplanation − In this example, we loaded the image from the local drive folder by using the imagecreatefrompng() function or we ... Read More

How to enable or disable interlace using imageinterlace() function in PHP?

Urmila Samariya
Updated on 09-Aug-2021 13:44:39

497 Views

imageinterlace() is an inbuilt PHP function that is used to enable or disable interlace in an image. It is a method of encoding a bitmap image such that a person who has partially received it sees a degraded copy of the entire image.Interlacing an image lets users see portions of it as it loads, and it takes different forms depending on the image type. The non-interlaced JPEGs appear line-by-line. To enable interlacing on picture, we can simply call this function with the second parameter set to 1, or set to 0 (zero) to disable it.Syntaxint imageinterlace(resource $image, int $interlace)Parametersimageinterlace() takes ... Read More

How to set a single pixel using imagesetpixel() function in PHP?

Urmila Samariya
Updated on 09-Aug-2021 13:39:33

477 Views

imagesetpixel() is an inbuilt function in PHP that is used to set a single pixel at the listed coordinate.Syntaxbool imagesetpixel(resource $image, int $x, int $y, int $color)Parametersimagesetpixel() accepts four parameters: $image, $x, $y and $color.$image − Specifies the image resource to work on.$x − Specifies the x-coordinate of the pixel.$y − Specifies the y-coordinate of the pixel.$color − Specifies the color of the pixel.Return Values −imagesetpixel() returns True on success and False on failure.Example 1OutputExample 2Output

Advertisements