Download Document 7760007

Survey
yes no Was this document useful for you?
   Thank you for your participation!

* Your assessment is very important for improving the work of artificial intelligence, which forms the content of this project

Document related concepts

Object-relational impedance mismatch wikipedia, lookup

Microsoft SQL Server wikipedia, lookup

Clusterpoint wikipedia, lookup

Open Database Connectivity wikipedia, lookup

Relational model wikipedia, lookup

Database model wikipedia, lookup

Transcript
Getting Started with PHP
To really understand the results of this process, we need to look at welcome1.php.
Create it as a new HTML file, but this time note the .php extension — this tells
the Web server that it can expect to interpret some PHP code in the file. In the
body of this new file, type:
<?php
$name = $_GET['name'];
echo( "Welcome to our Website, $name!" );
?>
Now, if you use the link in the first file to load this second file, you'll see that
the page says "Welcome to our Website, Kevin!"
PHP automatically creates an array variable called $_GET1 that contains any values
passed in the query string. $_GET is an associative array, so the value of the name
variable passed in the query string can be accessed as $_GET['name']. Our script
assigns this value to an ordinary PHP variable ($name) and then displays it as
part of a text string using the echo function.
register_globals before PHP 4.2
In versions of PHP prior to 4.2, the register_globals setting in php.ini was set to On
by default. This setting tells PHP to create automatically ordinary variables for all the
values supplied in the request. In the previous example, the $name = $_GET['name'];
line is completely unnecessary if the register_globals setting were set to On, since PHP
would do it automatically. Although the convenience of this feature was one aspect of
PHP that helped to make it such a popular language in the first place, novice developers
could easily leave security holes in sensitive scripts with it enabled.
For a full discussion of the issues surrounding register_globals, see my article Write
Secure Scripts with PHP 4.2!i at sitepoint.com.
You can pass more than one value in the query string. Let's look at a slightly
more complex version of the same example. Change the link in the HTML file
to read as follows (this is welcome2.html in the code archive):
<a href="welcome2.php?firstname=Kevin&lastname=Yank"> Hi,
I'm Kevin Yank! </a>
1
Prior to PHP 4.1, this variable was called $HTTP_GET_VARS. This variable name remains in current
PHP versions for backwards compatibility. If your server has an older version of PHP installed, or if
you're writing a script that must be compatible with older versions, you should use $HTTP_GET_VARS
instead of $_GET.
i
http://www.sitepoint.com/article.php/758
56