What is the “?” symbol in URL used for in php?

Good questions, briefly,

  1. “?” stands for the start of querying
    string which contains the data to be
    passed to the server. in this case
    you are passing user=roa3 to
    profile.php page. You can get the
    data by using $_GET[‘user’] within
    profile.php. querystring is one of the methods to send data to the server from client agent. The other one places the data in HTTP body and POST to the server, you don’t see the HTTP POST data directly from browser.

  2. querystring can be edited by user
    and it is visible to the public. If
    www.website.com/profile.php?user=roa3
    is intended to be public then it is
    fine, otherwise you may want to use
    session to get current user’s
    context.

  3. it is a flexible way to pass data to
    the server, but it is visible and
    editable to the users, for some
    sensitive data, at least produce
    some kind of hash before attaching
    it to the querystring, this prevents
    users to edit it or understanding
    the meaning of it. However this
    doesn’t prevent a decent hacker to
    do something wrong about your
    website. Different browsers support different max length of URL, the lengthy URL is made up by those querystring parameters. If you want to send large amount of data, place the data in the HTTP body and POST to the server.

Leave a Comment