top button
Flag Notify
    Connect to us
      Site Registration

Site Registration

How var_dump() function works in PHP?

+1 vote
371 views
How var_dump() function works in PHP?
posted Jul 4, 2014 by Amritpal Singh

Share this question
Facebook Share Button Twitter Share Button LinkedIn Share Button

2 Answers

+1 vote

This function displays structured information about one or more expressions that includes its type and value. Arrays and objects are explored recursively with values indented to show structure.

var_dump() used for debugging purpose in PHP.

For Example:

In array you want to know what are the values are there.

<?php
$a = array(1, 2, array("a", "b", "c"));
var_dump($a); 
?>

Output for above example:

array(3) {
  [0]=>
  int(1)
  [1]=>
  int(2)
  [2]=>
  array(3) {
    [0]=>
    string(1) "a"
    [1]=>
    string(1) "b"
    [2]=>
    string(1) "c"
  }
}
answer Jul 8, 2014 by anonymous
0 votes

The PHP var_dump() function returns the data type and value of variables.

For example:

<?php
$f=10.3;
var_dump($f);
?>

OUTPUT:

float 10.3
answer Jul 8, 2014 by Rahul Mahajan
Similar Questions
0 votes

If I am using an editor such as Eclipse to analyze a large PHP system and I want to find the file that a function is declared in then I can search for it. I think that the (right-click) context menu for the function sometimes has an item to open the declaration but that does not always work. The same for an include statement; even if I don't know what the path will be during execution and even if the source is in multiple folders, I can search for the file. For large systems however all that can take time (my time).

Is there a tool that can process thousands (at least a couple thousand) files and produce data of what file that a called function exists in and where a function is called from? In other words, caller/called data. I understand the technical challenges. In PHP includes are processed during execution so I know it might not be possible but I am asking if there is anything that can do it as much as possible.

+1 vote

I'm writing my first php extension and I need to list included files (in PHP script) from RINIT function, but I cannot figure out how.

I deep into PHP source code and I think it's related to EG(included_files), but I can't to access the list.

PHP_RINIT_FUNCTION(extname)
{
 // SAPI NAME AND PHP SCRIPT FILE HANDLE PATH
 char *pt_var_sapi_name = sapi_module.name;
 char *pt_var_file_handle_path = SG(request_info).path_translated;

 // HOW CAN I USE EG(included_files) to get included files list?

 return SUCCESS;
}
...