Is it possible to dump all global variables in a PHP script? Say this is my code:
<?php $foo = 1; $bar = "2"; include("blah.php"); dumpall(); // displays $foo, $bar and all variables created by blah.php
Also, is it possible to dump all defined constants in a PHP script.
The list() function is used to assign values to a list of variables in one operation. Note: Prior to PHP 7.1, this function only worked on numerical arrays.
PHP has three different variable scopes: local. global. static.
PHP $ and $$ Variables. The $var (single dollar) is a normal variable with the name var that stores any value like string, integer, float, etc. The $$var (double dollar) is a reference variable that stores the value of the $variable inside it.
PHP $_POST is a PHP super global variable which is used to collect form data after submitting an HTML form with method="post". $_POST is also widely used to pass variables.
Use get_defined_vars
and/or get_defined_constants
$arr = get_defined_vars(); print_r($arr);
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With