Using class
CGI
gives you access to HTML query parameters in two
ways.
Suppose we are given a URL of
/cgi-bin/lookup?player=Miles%20Davis&year=1958
. You can access
the parameters ``
player
'' and ``
year
'' using
CGI#[]
directly:
require 'cgi'
|
cgi = CGI.new
|
cgi['player']
|
� |
["Miles Davis"]
|
cgi['year']
|
� |
["1958"]
|
Or, you can retrieve all parameters as a
Hash
:
require 'cgi'
|
cgi = CGI.new
|
h = cgi.params
|
h['player']
|
� |
["Miles Davis"]
|