Re: What is "app.php?ph=cus&id=4"?

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Fri, Jun 4, 2010 at 09:54, Michael Calkins <michaelcalkins@xxxxxxxx> wrote:
>
> I would google this but I have no idea what this method is or how it works.
> app.php?ph=cus&id=4
> Can some tell me what this either called or how it works?Can I get a tutorial for it please?

    Split up, it is:

        app.php             The filename and extension
        ?ph=cus&id=4     An HTTP query string

            ?                   Start of HTTP query string
            ph                 A parameter name 'ph' which is
accessible in this case via the $_GET superglobal array
            =                   The equals operator assigns a value to
a variable
            cus                The value of the parameter 'ph'
assigned in the HTTP query string given
            &                  The ampersand indicates that another
parameter (variable) will be concatenated with the HTTP query string
            id                  A second parameter name 'id'
            =                   Again, for variable assignment
            4                   The value of the 'id' variable
assigned in the HTTP query string given

    To read this information, the app.php script could be accessed in
a regular web browser with the query string given appended as you
provided.  If it's accessed via an HTTP request to a web server or
other PHP-enabled application, the code to parse the information could
be as follows:

<?php

/***
  * To see if a specific parameter was passed within
  * the HTTP query string, we can simple check the
  * $_GET superglobal like any other array, like so:
  */
if (isset($_GET['foo'])) {
    echo "The 'foo' parameter was passed to me, and equals '".$foo."'";
}

// Simple check to see if a variable equals a static value or not
if ($_GET['ph'] == 'cus') {
    echo "Yes, 'ph' equals 'cus'.";
} else {
    echo "No, 'ph' does not equal 'cus'.";
}

// Dump the array to the screen without basic details
var_dump($_GET);

// Dump the array without details, but with simple text formatting
echo "<pre>".PHP_EOL;
print_r($_GET);
echo "</pre>".PHP_EOL;

// Print it all out with basic formatting
foreach ($_GET as $k => $v) {
    echo "<b>".$k." = ".$v."<br />".PHP_EOL;
}
?>


    For more information, check the PHP manual and Google for
superglobals and the fundamentals of using PHP in a web-based
environment.

-- 
</Daniel P. Brown>
daniel.brown@xxxxxxxxxxxx || danbrown@xxxxxxx
http://www.parasane.net/ || http://www.pilotpig.net/
We now offer SAME-DAY SETUP on a new line of servers!

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux