Data Structure
Networking
RDBMS
Operating System
Java
MS Excel
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
imagefilledrectangle() function in PHP
The imagefilledrectangle() function draws a filled rectangle.
Syntax
imagefilledrectangle( $img, $x1, $y1, $x2, $y2, $color )
Parameters
image
Create a blank image with imagecreatetruecolor().x1
x-coordinate for point 1.y1
y-coordinate for point 1.x2
x-coordinate for point 2.y2
y-coordinate for point 2.color
The fill color.
Return
The imagefilledrectangle() function returns TRUE on success or FALSE on failure.
Example
The following is an example:
<?php
// Create an image
$img = imagecreatetruecolor(500, 300);
$color = imagecolorallocate($img, 0, 128, 128);
imagefilledrectangle($img, 30, 30, 470, 270, $color);
header("Content-type: image/png");
imagepng($img);
imagedestroy($img);
?>
Output
The following is the output:

Advertisements