advice for passing string variable in PHP - cómo pasar una variable si tiene espacios en PHP?
For example, i want to pass a datetime variable using PHP to another PHP script.
The main problem was how to handle the spaces, such as the following: 2011-01-29 08:50:00 ???
well, my solution was to put together the variable using the explode function.
So the variable must be converted to 2011-01-29_08:50:00, doing this, we have only one string.
$fecha_entrada=explode(" ",$datein);
$fecha_salida=explode(" ",$dateout);
$datein2=$fecha_entrada[0]."_".$fecha_entrada[1];
$dateout2=$fecha_salida[0]."_".$fecha_salida[1];
when the other script receives the variable, again with the explode() function we separate the string getting it back to its original value.
$datein2 = $_GET['datein']; //variable viene con guión, la vamos a quitar
$dateout2 = $_GET['dateout']; //variable viene con guión, la vamos a quitar
//procesando variables de fechas recibidas desde un error:
$entree=explode("_",$datein2); //separando variables del guión bajo
$sortie=explode("_",$dateout2);
$datein=$entree[0]." ".$entree[1]; // regresando las variables a su estado natural. ay ay ay!
$dateout=$sortie[0]." ".$sortie[1];
Suscribirse a:
Enviar comentarios (Atom)
0 comentarios:
Publicar un comentario en la entrada