diff --git a/chapters/tutorial.xml b/chapters/tutorial.xml index 1a6b07c9ed..6db7c95813 100644 --- a/chapters/tutorial.xml +++ b/chapters/tutorial.xml @@ -1,5 +1,5 @@ - + A simple tutorial @@ -30,7 +30,7 @@ any extra tools. Think of these PHP-enabled files as simple HTML files with a whole new family of magical tags that let you do all sorts of things. Most web hosts offer PHP support, but if your - host does not consider reading the + host does not, consider reading the PHP Links section for resources on finding PHP enabled web hosts. @@ -56,7 +56,7 @@ Your first PHP-enabled page Create a file named hello.php and put it - in your web servers root directory (DOCUMENT_ROOT) + in your web server's root directory (DOCUMENT_ROOT) with the following content: @@ -69,17 +69,17 @@ PHP Test - Hello World

"; ?> + Hello World

'; ?> ]]> - Use your browser to access the file with your web access URL, ending + Use your browser to access the file with your web server's URL, ending with the "/hello.php" file reference. When developing locally this url will be something like http://localhost/hello.php or http://127.0.0.1/hello.php but this depends on the - web servers configuration. Although this is outside the scope of this + web server's configuration. Although this is outside the scope of this tutorial, see also the DocumentRoot and ServerName directives in your web server's configuration file (for Apache, this is &httpd.conf;). @@ -113,14 +113,14 @@ statement.
- If you tried this example and it did not output anything, or it prompted + If you tried this example and it did not output anything, it prompted for download, or you see the whole file as text, chances are that the server you are on does not have PHP enabled. Ask your administrator to enable it for you using the Installation chapter - of the manual. If you are developing locally, also read the + of the manual. If you are developing locally, also read the installation chapter to make sure everything is configured - properly. If problems continue to persist, do not hesitate to use one of + properly. If the problems persist, do not hesitate to use one of the many PHP support options. @@ -137,7 +137,7 @@ There are many text editors and Integrated Development Environments (IDEs) that you can use to create, edit and manage PHP files. A partial list of - these tools is maintained at PHP Editor's + these tools is maintained at PHP Editors List. If you wish to recommend an editor, please visit the above page and ask the page maintainer to add the editor to the list. Having an editor with syntax highlighting can be helpful. @@ -156,14 +156,14 @@ A Note on Windows Notepad - + If you are writing your PHP scripts using Windows Notepad, you will need to ensure that your files are saved with the .php extension. (Notepad adds a .txt extension to files automatically unless you take one of the following steps to prevent it.) When you save the file and are prompted to provide a name for the file, place the filename in quotes - (i.e. "hello.php"). Alternately, you can click on the - 'Text Documents' drop-down menu in the save dialog box and change the setting + (i.e. "hello.php"). Alternatively, you can click on the + 'Text Documents' drop-down menu in the 'Save' dialog box and change the setting to "All Files". You can then enter your filename without quotes. @@ -189,14 +189,14 @@ sends as part of the HTTP request. This information is stored in a variable. Variables always start with a dollar-sign in PHP. The variable we are interested in right now - is $_SERVER["HTTP_USER_AGENT"]. + is $_SERVER['HTTP_USER_AGENT']. $_SERVER is a special reserved PHP variable that contains all web server information. It is known as an autoglobal (or superglobal). See the related manual page on - autoglobals + superglobals for more information. These special variables were introduced in PHP 4.1.0. Before this time, we used the older $HTTP_*_VARS arrays instead, @@ -213,7 +213,7 @@ Printing a variable (Array element) + ]]> @@ -231,8 +231,8 @@ Mozilla/4.0 (compatible; MSIE 5.01; Windows NT 5.0) Arrays can be very useful. - $_SERVER is just one variable that is automatically - made available to you by PHP. A list can be seen in the + $_SERVER is just one variable that PHP automatically + makes available to you. A list can be seen in the Reserved Variables section of the manual or you can get a complete list of them by creating a file that looks like this: @@ -265,8 +265,8 @@ Mozilla/4.0 (compatible; MSIE 5.01; Windows NT 5.0) "; +if (strpos($_SERVER['HTTP_USER_AGENT'], 'MSIE') !== false) { + echo 'You are using Internet Explorer
'; } ?> ]]> @@ -295,8 +295,8 @@ You are using Internet Explorer
The second concept we introduced was the strpos function call. strpos is a function built into PHP which searches a string for another string. In this case we are - looking for "MSIE" (so-called needle) inside - $_SERVER["HTTP_USER_AGENT"] (so-called haystack). If + looking for 'MSIE' (so-called needle) inside + $_SERVER['HTTP_USER_AGENT'] (so-called haystack). If the needle is found inside the haystack, the function returns the position of the needle relative to the start of the haystack. Otherwise, it returns &false;. If it does not return &false;, the

strpos must have returned non-false

You are using Internet Explorer
@@ -386,15 +386,15 @@ if (strpos($_SERVER["HTTP_USER_AGENT"], "MSIE") !== false) { There is nothing special about this form. It is a straight HTML form with no special tags of any kind. When the user fills in this form and hits the submit button, the action.php page - is called. In this file you would have something like this: + is called. In this file you would write something like this:
Printing data from our form . -You are years old. +Hi . +You are years old. ]]> @@ -402,17 +402,16 @@ You are years old. It should be obvious what this does. There is nothing more to it. - The $_POST["name"] and $_POST["age"] + The $_POST['name'] and $_POST['age'] variables are automatically set for you by PHP. Earlier we - used the $_SERVER autoglobal, now above we just + used the $_SERVER autoglobal; above we just introduced the $_POST autoglobal which contains all POST data. Notice how the method of our form is POST. If we used the @@ -449,7 +448,7 @@ You are 22 years old. $_FILES, $_ENV, $_REQUEST, and $_SESSION. The older $HTTP_*_VARS arrays, such as - $HTTP_POST_VARS, still exist and have since PHP 3. + $HTTP_POST_VARS, still exist as they have since PHP 3. &avail.register-long-arrays; @@ -463,7 +462,7 @@ You are 22 years old. off by default in &php.ini;. The preferred method of accessing these values is via the autoglobal arrays mentioned above. Older scripts, books, and tutorials may rely on this - directive being on. If on, for example, one could use + directive being on. If it were on, for example, one could use $id from the URL http://www.example.com/foo.php?id=42. Whether on or off, $_GET['id'] is available.