Skip to content
geeksforgeeks
  • Tutorials
    • Python
    • Java
    • Data Structures & Algorithms
    • ML & Data Science
    • Interview Corner
    • Programming Languages
    • Web Development
    • CS Subjects
    • DevOps And Linux
    • School Learning
    • Practice Coding Problems
  • Courses
    • DSA to Development
    • Get IBM Certification
    • Newly Launched!
      • Master Django Framework
      • Become AWS Certified
    • For Working Professionals
      • Interview 101: DSA & System Design
      • Data Science Training Program
      • JAVA Backend Development (Live)
      • DevOps Engineering (LIVE)
      • Data Structures & Algorithms in Python
    • For Students
      • Placement Preparation Course
      • Data Science (Live)
      • Data Structure & Algorithm-Self Paced (C++/JAVA)
      • Master Competitive Programming (Live)
      • Full Stack Development with React & Node JS (Live)
    • Full Stack Development
    • Data Science Program
    • All Courses
  • PHP Tutorial
  • PHP Exercises
  • PHP Array
  • PHP String
  • PHP Calendar
  • PHP Filesystem
  • PHP Math
  • PHP Programs
  • PHP Array Programs
  • PHP String Programs
  • PHP Interview Questions
  • PHP GMP
  • PHP IntlChar
  • PHP Image Processing
  • PHP DsSet
  • PHP DsMap
  • PHP Formatter
  • Web Technology
Open In App
Next Article:
PHP | imagedashedline() Function
Next article icon

PHP | imagedashedline() Function

Last Updated : 23 Aug, 2019
Comments
Improve
Suggest changes
Like Article
Like
Report
The imagedashedline() function is an inbuilt function in PHP which is used to draw a dashed line. This function returns TRUE on success and returns FALSE otherwise. Syntax:
bool imagedashedline( $image , $x1 , $y1 , $x2 , $y2 , $color )
Parameters: This function accepts six parameters as mentioned above and described below:
  • $image: The imagecreatetruecolor() function is used to create a blank image in a given size.
  • $x1: This parameter is used to hold the top left x coordinate.
  • $y1: This parameter is used to hold the top left y coordinate. (0, 0) is the top left corner of the image.
  • $x2: This parameter is used to hold the bottom right x coordinate.
  • $y2: This parameter is used to hold the bottom right y coordinate.
  • $color: This variable contains the filled color identifier. A color identifier created with imagecolorallocate() function.
Return Value: This function returns TRUE on success or FALSE on failure. Below programs illustrate the imagedashedline() function in PHP. Program 1: php
<?php  // Create the size of image or blank image $image = imagecreatetruecolor(400, 300);  // Set the background color of image $background_color = imagecolorallocate($image,  0, 153, 0);   // Fill background with above selected color imagefill($image, 0, 0, $background_color);  // Set the color of dotted line in image $color = imagecolorallocate($image,  255, 255, 255);  // Draw a dashed line imagedashedline($image, 0, 0, 100, 150, $color);   // Output the image header("Content-type: image/png"); imagepng($image);   ?> 
Output: dotted image Program 2: php
<?php  // Create the size of image or blank image $image = imagecreatetruecolor(400, 300);  // Set the background color of image $background_color = imagecolorallocate($image,  0, 153, 0);   // Fill background with above selected color imagefill($image, 0, 0, $background_color);  // Set the color of dotted line in image $white = imagecolorallocate($image, 255, 255, 255);   // $value is an array variable stored color // code of dotted image $values = Array(                 $white,                  $white,                  $white,                  $white,                  IMG_COLOR_TRANSPARENT,                  IMG_COLOR_TRANSPARENT,                  IMG_COLOR_TRANSPARENT,                  IMG_COLOR_TRANSPARENT                 );   imagesetstyle($image, $values);   // Draw the dashed line imageline($image, 50, 150, 300, 150, IMG_COLOR_STYLED);   // Save the image header("Content-type: image/png"); imagepng($image);  ?> 
Output: dotted image Related Articles:
  • PHP | imagefilledpolygon() Function
  • PHP | imageellipse() Function
  • PHP | imagefilledellipse() Function
Reference: http://php.net/manual/en/function.imagedashedline.php

Next Article
PHP | imagedashedline() Function

V

Vishal_Khoda
Improve
Article Tags :
  • Misc
  • Web Technologies
  • PHP
  • PHP-function
Practice Tags :
  • Misc

Similar Reads

    PHP | imageline() Function
    The imageline() function is an inbuilt function in PHP which is used to set the draws a line between the two given points. Syntax: bool imageline( resource $image, int $x1, int $y1, int $x2, int $y2, int $color ) Parameters: This function accepts six parameters as mentioned above and described below
    2 min read
    PHP | imageaffine() Function
    The imageaffine() function is an inbuilt function in PHP which is used to get an image containing the affine transformed src image using an optional clipping area. Affine is a geometric transformation operation involving MATRICES. Syntax: resource imageaffine( resource $image, array $affine, array $
    2 min read
    PHP | imagesettile() Function
    The imagesettile() function is an inbuilt function in PHP which is used to set the tile image for filling the area. Syntax: bool imagesettile( $image, $tile ) Parameters: This function accepts two parameters as mentioned above and described below: $image: It is returned by one of the image creation
    2 min read
    PHP | imagesetclip() function
    The imagesetclip() function is an inbuilt function in PHP which is used to set the current clipping rectangle, i.e. the area beyond which no pixels will be drawn. Syntax: bool imagesetclip( resource $im, int $x1, int $y1, int $x2, int $y2 ) Parameters:This function accepts five parameters as mention
    2 min read
    PHP | ImagickDraw line() Function
    The ImagickDraw::line() function is an inbuilt function in Imagick library of PHP which is used to draw a line. This function draw the line using the current stroke color, stroke opacity, and stroke width.  Syntax:   bool ImagickDraw::line( $sx, $sy, $ex, $ey ) Parameters: This function accepts four
    1 min read
geeksforgeeks-footer-logo
Corporate & Communications Address:
A-143, 7th Floor, Sovereign Corporate Tower, Sector- 136, Noida, Uttar Pradesh (201305)
Registered Address:
K 061, Tower K, Gulshan Vivante Apartment, Sector 137, Noida, Gautam Buddh Nagar, Uttar Pradesh, 201305
GFG App on Play Store GFG App on App Store
Advertise with us
  • Company
  • About Us
  • Legal
  • Privacy Policy
  • In Media
  • Contact Us
  • Advertise with us
  • GFG Corporate Solution
  • Placement Training Program
  • Languages
  • Python
  • Java
  • C++
  • PHP
  • GoLang
  • SQL
  • R Language
  • Android Tutorial
  • Tutorials Archive
  • DSA
  • Data Structures
  • Algorithms
  • DSA for Beginners
  • Basic DSA Problems
  • DSA Roadmap
  • Top 100 DSA Interview Problems
  • DSA Roadmap by Sandeep Jain
  • All Cheat Sheets
  • Data Science & ML
  • Data Science With Python
  • Data Science For Beginner
  • Machine Learning
  • ML Maths
  • Data Visualisation
  • Pandas
  • NumPy
  • NLP
  • Deep Learning
  • Web Technologies
  • HTML
  • CSS
  • JavaScript
  • TypeScript
  • ReactJS
  • NextJS
  • Bootstrap
  • Web Design
  • Python Tutorial
  • Python Programming Examples
  • Python Projects
  • Python Tkinter
  • Python Web Scraping
  • OpenCV Tutorial
  • Python Interview Question
  • Django
  • Computer Science
  • Operating Systems
  • Computer Network
  • Database Management System
  • Software Engineering
  • Digital Logic Design
  • Engineering Maths
  • Software Development
  • Software Testing
  • DevOps
  • Git
  • Linux
  • AWS
  • Docker
  • Kubernetes
  • Azure
  • GCP
  • DevOps Roadmap
  • System Design
  • High Level Design
  • Low Level Design
  • UML Diagrams
  • Interview Guide
  • Design Patterns
  • OOAD
  • System Design Bootcamp
  • Interview Questions
  • Inteview Preparation
  • Competitive Programming
  • Top DS or Algo for CP
  • Company-Wise Recruitment Process
  • Company-Wise Preparation
  • Aptitude Preparation
  • Puzzles
  • School Subjects
  • Mathematics
  • Physics
  • Chemistry
  • Biology
  • Social Science
  • English Grammar
  • Commerce
  • World GK
  • GeeksforGeeks Videos
  • DSA
  • Python
  • Java
  • C++
  • Web Development
  • Data Science
  • CS Subjects
@GeeksforGeeks, Sanchhaya Education Private Limited, All rights reserved
We use cookies to ensure you have the best browsing experience on our website. By using our site, you acknowledge that you have read and understood our Cookie Policy & Privacy Policy
Lightbox
Improvement
Suggest Changes
Help us improve. Share your suggestions to enhance the article. Contribute your expertise and make a difference in the GeeksforGeeks portal.
geeksforgeeks-suggest-icon
Create Improvement
Enhance the article with your expertise. Contribute to the GeeksforGeeks community and help create better learning resources for all.
geeksforgeeks-improvement-icon
Suggest Changes
min 4 words, max Words Limit:1000

Thank You!

Your suggestions are valuable to us.

What kind of Experience do you want to share?

Interview Experiences
Admission Experiences
Career Journeys
Work Experiences
Campus Experiences
Competitive Exam Experiences