MANUAL DE PHP

(y algo mas)windsurf pozo izquierdo
Google
search for in the  
ELMARRAJO.COM mysql bulma desarrollo web linux fedora html ayuda

windsurf mercedes camper

get_defined_vars

(PHP 4 >= 4.0.4, PHP 5)

get_defined_vars --  Devuelve una matriz con todas la variables definidas

Descripción

array get_defined_vars ( void )

Esta función devuelve una matriz multidimensional que contiene una lista de todas las variables definidas, ya sean variables de entorno, de servidor, o definidas por el usuario, al interior del contexto en el que get_defined_vars() es llamado.

Valores retornados

Una matriz multidimensional con todas las variables.

Ejemplos

Ejemplo 1. Ejemplo de get_defined_vars()

<?php
$b
= array(1, 1, 2, 3, 5, 8);

$matriz = get_defined_vars();

// imprimir $b
print_r($matriz["b"]);

/* imprimir ruta al interpretre PHP (si es usado como CGI)
 * p.ej. /usr/local/bin/php */
echo $matriz["_"];

// imprimir los parametros de la linea de comandos, si existen
print_r($matriz["argv"]);

// imprimir todas las variables del servidor
print_r($matriz["_SERVER"]);

// imprimir todas las claves disponibles para las matrices de variables
print_r(array_keys(get_defined_vars()));
?>

Registro de cambios

VersiónDescripción
5.0.0 La variable $GLOBALS se incluye en los resultados de la matriz devuelta.



add a note add a note User Contributed Notes
get_defined_vars
sijmen at digitized dot nl
12-Jul-2004 08:11
I was wondering what the difference was between get_defined_vars() and the array $GLOBALS. If you call get_defined_vars() not from a function, then there is no difference. But, if you call it from inside a function or class, then it will only return the available variables inside that function/class.

- Sijmen Ruwhof
lbowerh at adelphia dot net
04-Jun-2004 08:19
Here is a function which generates a debug report for display or email
using get_defined_vars. Great for getting a detailed snapshot without
relying on user input.

<?php
function generateDebugReport($method,$defined_vars,$email="undefined"){
  
// Function to create a debug report to display or email.
   // Usage: generateDebugReport(method,get_defined_vars(),email[optional]);
   // Where method is "browser" or "email".

   // Create an ignore list for keys returned by 'get_defined_vars'.
   // For example, HTTP_POST_VARS, HTTP_GET_VARS and others are
   // redundant (same as _POST, _GET)
   // Also include vars you want ignored for security reasons - i.e. PHPSESSID.
  
$ignorelist=array("HTTP_POST_VARS","HTTP_GET_VARS",
  
"HTTP_COOKIE_VARS","HTTP_SERVER_VARS",
  
"HTTP_ENV_VARS","HTTP_SESSION_VARS",
  
"_ENV","PHPSESSID","SESS_DBUSER",
  
"SESS_DBPASS","HTTP_COOKIE");

  
$timestamp=date("m/d/y h:m:s");
  
$message="Debug report created $timestamp\n";

  
// Get the last SQL error for good measure, where $link is the resource identifier
   // for mysql_connect. Comment out or modify for your database or abstraction setup.
  
global $link;
  
$sql_error=mysql_error($link);
   if(
$sql_error){
    
$message.="\nMysql Messages:\n".mysql_error($link);
   }
  
// End MySQL

   // Could use a recursive function here. You get the idea ;-)
  
foreach($defined_vars as $key=>$val){
     if(
is_array($val) && !in_array($key,$ignorelist) && count($val) > 0){
      
$message.="\n$key array (key=value):\n";
       foreach(
$val as $subkey=>$subval){
         if(!
in_array($subkey,$ignorelist) && !is_array($subval)){
          
$message.=$subkey." = ".$subval."\n";
         }
         elseif(!
in_array($subkey,$ignorelist) && is_array($subval)){
           foreach(
$subval as $subsubkey=>$subsubval){
             if(!
in_array($subsubkey,$ignorelist)){
              
$message.=$subsubkey." = ".$subsubval."\n";
             }
           }
         }
       }
     }
     elseif(!
is_array($val) && !in_array($key,$ignorelist) && $val){
      
$message.="\nVariable ".$key." = ".$val."\n";
     }
   }

   if(
$method=="browser"){
     echo
nl2br($message);
   }
   elseif(
$method=="email"){
     if(
$email=="undefined"){
      
$email=$_SERVER["SERVER_ADMIN"];
     }

    
$mresult=mail($email,"Debug Report for ".$_ENV["HOSTNAME"]."",$message);
     if(
$mresult==1){
       echo
"Debug Report sent successfully.\n";
     }
     else{
       echo
"Failed to send Debug Report.\n";     
     }
   }
}
?>
Ruben Barkow(mail-> at web dot de)
06-May-2004 05:32
this does NOT work:
i tried to find out the name of a variable, that was sent to myfunction($in) with this code:
myfunction($in) {
   $e=array_reverse(get_defined_vars());
   echo "possible name for the variable in the function call: '";
   foreach ($e as $n=>$v){
       if ($v===$in) {
           echo $n;
           break;
       }
   }
   echo"'";
}

but:
get_defined_vars() doesent give back the variables outside of a function.
(the code does work in the main programcode)
php - fw2 - net
29-Dec-2003 03:21
biyectivo, above, is incorrect, at least as of PHP-4.3.3 which does indeed show variables from included/required files, as, IMO, it should. Very useful for debugging foreign code.
biyectivo at hotmail dot com
07-Jun-2003 04:16
Thankfully, get_defined_vars() does NOT return variables which are assigned during an include() call. This would be a big security hole. For example:

//---------------------------------------------------------
include("foo.php");
$var1 = "Hi";

$vars = get_defined_vars();
$ks = array_keys($vars);
  
   for ($i=0;$i<sizeof($ks);$i++)
   {
       echo $ks[$i]." --> ".$vars[$ks[$i]]."< br >";
   }
//---------------------------------------------------------

will return all server variables, then

   var1 --> Hi

but will NOT return

   pwd --> MyPassword

even if inside foo.php there is a line stating

$pwd = "MyPassword";
jgettys at gnuvox dot com
22-Feb-2002 07:09
Simple routine to convert a get_defined_vars object to XML.

function obj2xml($v, $indent='') {
  while (list($key, $val) = each($v)) {
   if ($key == '__attr') continue;
   // Check for __attr
   if (is_object($val->__attr)) {
     while (list($key2, $val2) = each($val->__attr)) {
       $attr .= " $key2=\"$val2\"";
     }
   }
   else $attr = '';
   if (is_array($val) || is_object($val)) {
     print("$indent<$key$attr>\n");
     obj2xml($val, $indent.'  ');
     print("$indent</$key>\n");
   }
   else print("$indent<$key$attr>$val</$key>\n");
  }
}

//Example object
$x->name->first = "John";
$x->name->last = "Smith";
$x->arr['Fruit'] = 'Bannana';
$x->arr['Veg'] = 'Carrot';
$y->customer = $x;
$y->customer->__attr->id='176C4';

$z = get_defined_vars();
obj2xml($z['y']);

will output:
<customer id="176C4">
  <name>
   <first>John</first>
   <last>Smith</last>
  </name>
  <arr>
   <Fruit>Bannana</Fruit>
   <Veg>Carrot</Veg>
  </arr>
</customer>

Citas célebres

La melancolía es el placer de estar triste.

Victor Hugo
Escritor francés
(1802-1885)
Citas en tu mail
©Contenidos Gratis

Ilusiones Opticas
ilusion_optica_008.jpg
Contenidos Web

Chiste de... Mamá, mamá
Hijo de vaca

- Mamá, mamá en el colegio me llaman hijo de vaca.

- Muuurmuraciones, hijo, Muuuurmuraciones.
Chistes en tu mail
©ContenidosGratis

Humor Gráfico
humor_grafico_012.jpg
Contenidos Web

Inicio | Acción | Estrategia | Palabras | Puzzles | Solitarios | Foro Trucos
Cake ManiaCake Mania
Jugadores: 6835
Categoría del juego: Acción
Objetivo del juego: Ayuda a Jill a recuperar la pastelería de su abuela llevando su propia pastelería; consigue clientes y gana dinero.
Rainbow WebRainbow Web
Jugadores: 2199
Categoría del juego: Puzzles
Objetivo del juego: Rompe un pegajoso hechizo y salva un reino de fantasía en Rainbow Web. Tendrás toneladas de diversión mientras juegas a este mágico desafío para la mente.
Mahjongg FortunaMahjongg Fortuna
Jugadores: 12462
Categoría del juego: Solitarios
Objetivo del juego: Velocidad y habilidad mental son las armas más importantes en esta versión de un antiguo juego asiático. Despeja el tablero lo antes posible haciendo clic en las fichas iguales y gánate la fama eterna de la puntuación más alta.
Chainz 2Chainz 2
Jugadores: 6955
Categoría del juego: Puzzles
Objetivo del juego: Entra en el mundo de las combinaciones con Chainz 2: Relinked, emocionante secuela del exitazo del año pasado, Chainz. Gira eslabones y crea combinaciones de 3 ó más.
DeliciousDelicious
Jugadores: 4405
Categoría del juego: Acción
Objetivo del juego: ¿Eres un as de la multitarea? ¿Quieres que tus clientes estén contentos? ¡Pues Delicious es tu juego! Sacia el apetito de los clientes y tenlos contentos; ¡no te arriesgues!
BookwormBookworm
Jugadores: 4568
Categoría del juego: Palabras
Objetivo del juego: Junta las letras para formar palabras. ¡Las palabras más largas valen más puntos!
ZumaZuma
Jugadores: 4976
Categoría del juego: Acción
Objetivo del juego: Controla el ídolo de la rana de piedra de los antiguos Zuma en este intrigante enigma de acción. ¡Dispara bolas para formar conjuntos de tres, pero si dejas que lleguen a la calavera dorada morirás!
Jewel of AtlantisJewel of Atlantis
Jugadores: 3798
Categoría del juego: Puzzles
Objetivo del juego: Descubre la ciudad hundida de la Atlántida y busca valiosos tesoros. Viaja más allá de las profundidades del mar y vive trepidantes aventuras en Jewel of Atlantis.
Jewel QuestJewel Quest
Jugadores: 3727
Categoría del juego: Puzzles
Objetivo del juego: Convierte la arena de la antigua selva en oro tan rápido como puedas juntando grupos de 3 elementos. ¡Los grupos más grandes valen más puntos!
Bejeweled 2Bejeweled 2
Jugadores: 3659
Categoría del juego: Puzzles
Objetivo del juego: Con cuatro modos de juego únicos y fascinantes, nuevas piezas de juego explosivas e imponentes fondos planetarios, Bejeweled 2 es mucho más adictivo que nunca.
Contenidos gratis en tu webSiguiente >>

Fotos divertidas
fotos_increibles_0238.jpg
Contenidos Web
microrobots avion deportes riesgo recetas cocina canaria juegos online gratis moto motociclismo horoscopos naranjas valencianas surf canarias montañismo ciudades turismo postales gratis library Horoscopos Diarios Windsurf Canarias
fregadero microondas placa electrica bañopreparar camper pantalla plananevera compresor electricacamper fiat ducato camper baño quimicomampara enrollable bañocamper aire climatizadofurgoneta surf windsurffurgoneta surf windsurftelevisor furgonetas camperfurgonetas camper cama

Sudoku del día
Nivel de dificultad: Fácil



Cómo jugar:
El juego consiste en colocar los números del 1 al nueve de tal forma que no se repita el mismo número en la columna, fila y caja (bloques 3x3 enmarcados).

©Contenidos Gratis | Sudoku en tu mail
Sucedió el...

30 de agosto de 1617

Fallece Santa Rosa de Lima, por la que se celebra el "Día de la Patrona de América".
Efemérides en tu mail
©Contenidos Gratis
windsurf canarias youtube porno canarias baleares valencia madrid fallera mayor campus party alcacer feria valencia fernando alonso loterias dinero inversiones violencia de genero makro empresas cartera soledad tolerancia metro valencia gobierno de españa violencia de genero UIMP navidad