Contents

PHP String Functions Complete Reference

PHP String Functions Complete Reference

The predefined math functions in PHP are used to handle mathematical operations with integer and float types. These math functions are built into PHP and do not require any additional installation.

Installation: These functions do not require any special installation. The complete list of PHP math functions is given below:

Example: A program illustrating the decbin() function in PHP:

				
					<?php
echo decbin(45);
?>

				
			

Output:

				
					101101

				
			
ImagickDraw::annotation()
Description: Draws text at specified coordinates on the image.
Example:
				
					$draw->annotation(50, 100, "Sample Text");
// Output: (draws "Sample Text" at position (50, 100))

				
			
ImagickDraw::arc()
Description: Draws an arc between two points with a specified start and end angle.
Example:
				
					$draw->arc(50, 50, 200, 200, 0, 90);
// Output: (draws an arc from 0° to 90° within the bounding box (50, 50) to (200, 200))

				
			
ImagickDraw::bezier()
Description: Draws a bezier curve using specified control points.
Example:
				
					$draw->bezier([[10, 10], [30, 90], [60, 30], [80, 80]]);
// Output: (draws a bezier curve passing through the defined points)

				
			
ImagickDraw::circle()
Description: Draws a circle with a center point and a point on the radius.
Example:
				
					echo chop("Hello World!  ");
// Output: Hello World!

				
			
ImagickDraw::getStrokeOpacity()
Description: Returns the opacity of stroked outlines.
Example:
				
					echo $draw->getStrokeOpacity();
// Output: (returns the opacity level of the stroke)

				
			
ImagickDraw::getStrokeWidth()
Description: Returns the stroke width used for outlines.
Example:
				
					echo $draw->getStrokeWidth();
// Output: (returns stroke width value)

				
			
ImagickDraw::line()
Description: Draws a line between two points.
Example:
				
					$draw->line(10, 10, 300, 300);
// Output: (draws a line from (10, 10) to (300, 300))

				
			
ImagickDraw::point()
Description: Draws a point at specified coordinates.
Example:
				
					$draw->point(150, 150);
// Output: (draws a point at coordinate (150, 150))

				
			
ImagickDraw::polygon()
Description: Draws a polygon using an array of vertex points.
Example:
				
					$draw->polygon([[10, 10], [100, 50], [50, 100]]);
// Output: (draws a polygon with vertices at the specified points)

				
			
ImagickDraw::polyline()
Description: Draws a series of connected lines through specified points.
Example:
				
					$draw->polyline([[10, 20], [30, 40], [50, 60], [70, 80]]);
// Output: (draws connected lines through the defined points)

				
			
ImagickDraw::rectangle()
Description: Draws a rectangle defined by two opposite corners.
Example:
				
					$draw->rectangle(10, 10, 200, 100);
// Output: (draws a rectangle from (10, 10) to (200, 100))

				
			
ImagickDraw::rotate()
Description: Applies rotation to the coordinate space.
Example:
				
					echo password_hash("mypassword", PASSWORD_DEFAULT);
// Output: $2y$10$...

				
			
ImagickDraw::roundRectangle()
Description: Draws a rectangle with rounded corners.
Example:
				
					$draw->roundRectangle(10, 20, 200, 150, 20, 20);
// Output: (draws a rectangle with rounded corners of radius 20)

				
			
ImagickDraw::scale()
Description: Applies scaling to the horizontal and vertical directions.
Example:
				
					$draw->scale(1.5, 1.2);
// Output: (scales coordinate space by 1.5 horizontally and 1.2 vertically)

				
			
ImagickDraw::setFillColor()
Description: Sets the color used for filling shapes.
Example:
				
					$draw->setFillColor('green');
// Output: (sets fill color to green)

				
			
ImagickDraw::setFillOpacity()
Description: Sets the opacity level for the fill color.
Example:
				
					$draw->setFillOpacity(0.5);
// Output: (sets fill opacity to 50%)

				
			
ImagickDraw::setFont()
Description: Sets the font for text drawing.
Example:
				
					$draw->setFont('Courier');
// Output: (sets text font to Courier)

				
			
ImagickDraw::setFontFamily()
Description: Sets the font family to use for text.
Example:
				
					$draw->setFontFamily('Arial');
// Output: (sets font family to Arial)

				
			
ImagickDraw::setFontSize()
Description: Specifies the font size for text.
Example:
				
					$draw->setFontSize(20);
// Output: (sets text font size to 20 points)

				
			
ImagickDraw::setFontStyle()
Description: Sets the style for text, such as italic or normal.
Example:
				
					$draw->setFontStyle(Imagick::STYLE_NORMAL);
// Output: (sets text font style to normal)

				
			
ImagickDraw::setFontWeight()
Description: Specifies the weight of the font for text.
Example:
				
					$draw->setFontWeight(700);
// Output: (sets font weight to bold)

				
			
ImagickDraw::setGravity()
Description: Sets the placement gravity for text.
Example:
				
					$draw->setGravity(Imagick::GRAVITY_SOUTHWEST);
// Output: (positions text relative to the southwest corner)

				
			
ImagickDraw::setStrokeAlpha()
Description: Specifies the opacity of stroke outlines.
Example:
				
					$draw->setStrokeAlpha(0.6);
// Output: (sets stroke opacity to 60%)

				
			
ImagickDraw::setStrokeColor()
Description: Sets the color for stroke outlines.
Example:
				
					$draw->setStrokeColor('blue');
// Output: (sets stroke color to blue)

				
			
ImagickDraw::setStrokeLineJoin()
Description: Defines the style of corners when paths are stroked.
Example:
				
					$draw->setStrokeAlpha(0.6);
// Output: (sets stroke opacity to 60%)

				
			
ImagickDraw::setStrokeMiterLimit()
Description: Sets the miter limit for the stroke.
Example:
				
					$draw->setStrokeMiterLimit(5);
// Output: (sets miter limit to 5)

				
			
ImagickDraw::setStrokeOpacity()
Description: Defines the opacity level for stroke outlines.
Example:
				
					$draw->setStrokeOpacity(0.9);
// Output: (sets stroke opacity to 90%)