philip Wed Jan 22 00:40:57 2003 EDT Modified files: /phpdoc/en/chapters tutorial.xml Log: Added many references to various PHP manual sections, information on how to develop locally (included where to get stuff for this), slightly modified the example, made multiple paragraphs into single ones for a few <notes>, and added some information on the usefullness of phpinfo(). Index: phpdoc/en/chapters/tutorial.xml diff -u phpdoc/en/chapters/tutorial.xml:1.10 phpdoc/en/chapters/tutorial.xml:1.11 --- phpdoc/en/chapters/tutorial.xml:1.10 Sat Sep 28 23:40:39 2002 +++ phpdoc/en/chapters/tutorial.xml Wed Jan 22 00:40:57 2003 @@ -1,5 +1,5 @@ <?xml version="1.0" encoding="iso-8859-1"?> -<!-- $Revision: 1.10 $ --> +<!-- $Revision: 1.11 $ --> <chapter id="tutorial"> <title>A simple tutorial</title> @@ -31,13 +31,29 @@ files with a whole new family of magical tags that let you do all sorts of things. </para> + <para> + Let's say you want to save precious bandwidth and develop locally. + In this case, you'll want to install a web server, such as + <link linkend="install.apache">Apache</link>, and of course + <ulink url="&url.php.downloads;">PHP</ulink>. You'll most likely + want to install a database as well, such as + <ulink url="&url.mysql.docs;">MySQL</ulink>. You can install + these individually or a simpler way is to <ulink + url="&url.installkits;">locate a pre-configured package</ulink> + that automatically installs all of these with just a few mouse + clicks. It's easy to setup a web server with PHP support on + any operating system, including Linux and Windows. In linux, + you may find <ulink url="&url.rpmfind;">rpmfind</ulink> helpful + for locating RPMs. + </para> </sect1> <sect1 id="tutorial.firstpage"> <title>Your first PHP-enabled page</title> <para> - Create a file named <filename>hello.php</filename> under your - webserver root directory with the following content: + Create a file named <filename>hello.php</filename> and put it + in your web servers root directory (<varname>DOCUMENT_ROOT</varname>) + with the following content: </para> <para> <example> @@ -49,13 +65,24 @@ <title>PHP Test</title> </head> <body> - <?php echo "Hello World<p>"; ?> + <?php echo "<p>Hello World</p>"; ?> </body> </html> ]]> </programlisting> + <simpara> + Use your browser to access the file with your web access URL, ending + with the "/hello.php" file reference. When developing locally this + url will be something like <literal>http://localhost/hello.php</literal> + or <literal>http://127.0.0.1/hello.php</literal> but this depends on the + web servers configuration. Although this is outside the scope of this + tutorial, see also the <varname>DocumentRoot</varname> and + <varname>ServerName</varname> directives in your web servers + configuration file. (on Apache this is <filename>httpd.conf</filename>). + If everything is setup correctly, this file will be parsed by PHP and + the following output will make it to your browser: + </simpara> <para> - The output of this script will be: <screen role="html"> <![CDATA[ <html> @@ -63,7 +90,7 @@ <title>PHP Test</title> </head> <body> - Hello World<p> + <p>Hello World</p> </body> </html> ]]> @@ -89,17 +116,19 @@ server you are on does not have PHP enabled. Ask your administrator to enable it for you using the <link linkend="installation">Installation</link> chapter - of the manual. If you want to develop PHP scripts locally, see - the <ulink url="&url.php.downloads;">downloads</ulink> section. - You can develop locally on any Operating system, be sure to - install an appropriate web server too. + of the manual. If you're developing locally, also read the + installation chapter to make sure everything is configured + properly. If problems continue to persist, don't hesitate to use one of + the many <ulink url="&url.php.support;">PHP support</ulink> options. </para> <para> The point of the example is to show the special PHP tag format. In this example we used <literal><?php</literal> to indicate the start of a PHP tag. Then we put the PHP statement and left PHP mode by adding the closing tag, <literal>?></literal>. You may jump in - and out of PHP mode in an HTML file like this all you want. + and out of PHP mode in an HTML file like this all you want. For more + details, read the manual section on <link linkend="language.basic-syntax"> + basic PHP syntax</link>. </para> <note> <title>A Note on Text Editors</title> @@ -107,8 +136,9 @@ 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 <ulink url="&url.phpeditorlist;">PHP Editor's - List</ulink>. If you wish to recommend an editor, please visit the above - page and ask the page maintainer to add the editor to the list. + List</ulink>. 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. </para> </note> @@ -116,13 +146,9 @@ <title>A Note on Word Processors</title> <para> Word processors such as StarOffice Writer, Microsoft Word and Abiword are - not good choices for editing PHP files. - </para> - - <para> - If you wish to use one for this test script, you must ensure that you save - the file as PLAIN TEXT or PHP will not be able to read and execute the - script. + not good choices for editing PHP files. If you wish to use one for this + test script, you must ensure that you save the file as PLAIN TEXT or PHP + will not be able to read and execute the script. </para> </note> @@ -132,20 +158,23 @@ 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.) - </para> - - <para> - When you save the file and are prompted to provide a name for the file, - place the filename in quotes (i.e. "hello.php"). - </para> - - <para> - Alternately, 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. + 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. "<filename>hello.php</filename>"). Alternately, 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. </para> </note> + + <para> + Now that you've successfully created a simple PHP script that works, it's + time to create the most famous PHP script! Make a call to the + <function>phpinfo</function> function and you'll see a lot of useful + information about your system and setup such as available + <link linkend="language.variables.predefined">Predefined Variables</link>, + loaded PHP modules, and <link linkend="configuration">configuration</link> + settings. Take some time and review this important information. + </para> </sect1>
-- PHP Documentation Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php