Javatpoint Logo
Javatpoint Logo

PHP Imagestring() Function

Imagestring( ) function is another inbuilt PHP function mainly used to draw a horizontal string. The function works using the x and y-axis, used to set coordinates for the starting point from where the picture has to be drawn. The origin coordinates ( 0, 0 ) are in the browsing window's top-left corner. We can set the coordinates accordingly from the origin to get the resulting picture according to our needs.

Syntax

Parameters: This function accepts six parameters

S.No Parameter Description Optional / mandatory
1 $ image This parameter is used to define the size of the image we want to display. This parameter is used by an image resource like the imagecreatetruecolor ( ) function, which returns an image source. Mandatory
2 $ font This parameter is used to define the font size of the string we want to display. It is used as numeric 1, 2, 3 . . . the higher the number, the large the font, and vice a verse. optional
3 $ x This parameter is used to set the desired image's x-coordinates. Starting from the origin mandatory
4 $ y This parameter is used to set the desired image's y-coordinates. Starting from the origin mandatory
5 $ string This parameter is used to define the string which will be printed mandatory
6 $ color This parameter is used to define the color of the image. This parameter is used for creating a color identifies like the imagecolorallocate ( ) function optional

The imagestring( ) function returns TRUE on successful execution of the program and FALSE on a failed attempt.

Program 1: PHP program to display the use of imagestring( ) function

Output

PHP Imagestring() Function

Here in this program, we have declared various variables like $image to define the size of the image that we require, $background color to define the color of background we require, $text color to define the color of text we require. We have used the image string ( ) function to declare the complete string we want to display as an image. To display the output of the image, we have used an inbuilt PHP command header and imagepng to display on the browser.

Program 2: PHP program to display the use of imagestring( ) function

Output

PHP Imagestring() Function

Here in this program, we have declared various variables like $image to define the size of the image that we require, $background color to define the color of background we require, $text color to define the color of text we require. We have used the imagestring( ) function to declare the complete string we want to display as an image. To display the output of the image, we have used an inbuilt PHP command header and imagepng to display on the browser.

Program 3: PHP program to display the use of imagestring( ) function

Output

PHP Imagestring() Function

Here in this program, we have declared various variables like $image to define the size of the image that we require, $background color to define the color of background we require, $text color to define the color of text we require. We have used the imagestring( ) function to declare the complete string we want to display as an image. To display the output of the image, we have used an inbuilt PHP command header and imagepng to display on the browser.


Next TopicPHP Classes





Youtube For Videos Join Our Youtube Channel: Join Now

Feedback


Help Others, Please Share

facebook twitter pinterest

Learn Latest Tutorials


Preparation


Trending Technologies


B.Tech / MCA