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 var_dump() Function
Next article icon

PHP var_dump() Function

Last Updated : 30 Sep, 2024
Comments
Improve
Suggest changes
Like Article
Like
Report

The var_dump() function in PHP is used to display structured information about one or more variables. The structured information means type and value of the given variable. It outputs not just the value of the variable but also its data type and, in the case of arrays or objects, all of their structure.

Syntax

var_dump(mixed $value, mixed ...$values): void

Parameters

  • $value: The variable or value to be dumped.
  • $values: Additional variables to dump (optional).

Return Value

This function does not return any value. It outputs the result directly to the browser or console.

Example 1: Basic example of var_dump() function.

PHP
<?php  $number = 123; $string = "Hello, World!"; $array = [1, 2, 3, "PHP", true];  var_dump($number); var_dump($string); var_dump($array);  ?> 

Output
int(123) string(13) "Hello, World!" array(5) {   [0]=>   int(1)   [1]=>   int(2)   [2]=>   int(3)   [3]=>   string(3) "PHP"   [4]=>   bool(true) } 

Example 2: The use of var_dump() function on objects.

PHP
<?php  class Test {   public $name = "PHP";   public $version = 8; }  $obj = new Test(); var_dump($obj);  ?> 

Output
object(Test)#1 (2) {   ["name"]=>   string(3) "PHP"   ["version"]=>   int(8) } 

Example 3: The use of var_dump() function in nested array.

PHP
<?php    $nestedArr = [   	"languages" => ["PHP", "JavaScript", "Python"],   	"frameworks" => ["Laravel", "React", "Django"] ];  var_dump($nestedArr);  ?> 

Output
array(2) {   ["languages"]=>   array(3) {     [0]=>     string(3) "PHP"     [1]=>     string(10) "JavaScript"     [2]=>     string(6) "Python"   }   ["frameworks"]=>   array(3) {     [0]=>     string(7) "Laravel"     [1]=>     string(5) "React"     [2]=>     string(6) "Django"   } } 

Next Article
PHP var_dump() Function

P

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

Similar Reads

    PHP debug_zval_dump() Function
    The debug_zval_dump() is an inbuilt function in PHP where the string representation of an internal zval structure will be dumped to the output. Syntax: debug_zval_dump(mixed $value, mixed ...$values): voidParameters: This function has two parameters: value: This parameter specifies the variable or v
    1 min read
    PHP | var_export() Function
    The var_export() is a built-in function in PHP which is used to return the structured value(information) of a variable that is passed to this function as a parameter. This function is similar to the var_dump() function.Syntax: var_export($var, $return) Parameters: This function accepts two parameter
    1 min read
    PHP strval() Function
    The PHP strval() function converts a given variable to a string. It takes a scalar variable (like integers, floats, and booleans) and converts it to its string representation. For arrays, objects, and resources, it does not work and may produce unexpected results.Syntaxstrval( $variable ) Parameter:
    3 min read
    PHP compact() Function
    The compact() function is an inbuilt function in PHP and it is used to create an array using variables. This function is the opposite of the extract() function. It creates an associative array whose keys are variable names and their corresponding values are array values. Syntax: array compact("varia
    2 min read
    PHP | get_defined_vars() Function
    The get_defined_vars() function is an inbuilt function in PHP which is used to returns an array of all defined variables. This function returns a multidimensional array which contains all the list of variables, environment etc. Syntax: array get_defined_vars( void ) Parameters: This function does no
    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