PHP tips: Comprobar parámetros get

10Feb09

Hoy he dado casualmente con una manera distinta de capturar un parámetro por GET. Antes lo que hacía era:

        if ($_GET['action'])
        {
            $action = $_GET['action'];
            if ($_GET['email'])
            {
                $email = $_GET['email'];
                echo "action = ".$action." and email = ".$email;
            }
        }

Y ahora lo que hago es lo siguiente:

        if ($action = $_GET['action'])
        {
            if ($email = $_GET['email'])
            {
                echo "action = ".$action." and email = ".$email;
            }
        }

Para desarrolladores de Zend Framework, el codigo sería:

if ($email = $this->_request->get('email'))
{
    echo "email = ".$email;
}

Nota: Esta semana en clase de Project Management … no están nada mal :)

No comments yet.

Write a comment: