Sophie

Sophie

distrib > Mandriva > 9.1 > ppc > media > main > by-pkgid > 0afeee9cca140e167a996902b9a677c5 > files > 3223

php-manual-en-4.3.0-2mdk.noarch.rpm

<HTML
><HEAD
><TITLE
>Your first PHP-enabled page</TITLE
><META
NAME="GENERATOR"
CONTENT="Modular DocBook HTML Stylesheet Version 1.7"><LINK
REL="HOME"
TITLE="PHP Manual"
HREF="index.html"><LINK
REL="UP"
TITLE="A simple tutorial"
HREF="tutorial.html"><LINK
REL="PREVIOUS"
TITLE="A simple tutorial"
HREF="tutorial.html"><LINK
REL="NEXT"
TITLE="Something Useful"
HREF="tutorial.useful.html"><META
HTTP-EQUIV="Content-type"
CONTENT="text/html; charset=ISO-8859-1"></HEAD
><BODY
CLASS="sect1"
BGCOLOR="#FFFFFF"
TEXT="#000000"
LINK="#0000FF"
VLINK="#840084"
ALINK="#0000FF"
><DIV
CLASS="NAVHEADER"
><TABLE
SUMMARY="Header navigation table"
WIDTH="100%"
BORDER="0"
CELLPADDING="0"
CELLSPACING="0"
><TR
><TH
COLSPAN="3"
ALIGN="center"
>PHP Manual</TH
></TR
><TR
><TD
WIDTH="10%"
ALIGN="left"
VALIGN="bottom"
><A
HREF="tutorial.html"
ACCESSKEY="P"
>Prev</A
></TD
><TD
WIDTH="80%"
ALIGN="center"
VALIGN="bottom"
>Chapter 2. A simple tutorial</TD
><TD
WIDTH="10%"
ALIGN="right"
VALIGN="bottom"
><A
HREF="tutorial.useful.html"
ACCESSKEY="N"
>Next</A
></TD
></TR
></TABLE
><HR
ALIGN="LEFT"
WIDTH="100%"></DIV
><DIV
CLASS="sect1"
><H1
CLASS="sect1"
><A
NAME="tutorial.firstpage"
></A
>Your first PHP-enabled page</H1
><P
>&#13;    Create a file named <TT
CLASS="filename"
>hello.php</TT
> and put it
    in your web servers root directory (<TT
CLASS="varname"
>DOCUMENT_ROOT</TT
>) 
    with the following content:
   </P
><P
>&#13;    <TABLE
WIDTH="100%"
BORDER="0"
CELLPADDING="0"
CELLSPACING="0"
CLASS="EXAMPLE"
><TR
><TD
><DIV
CLASS="example"
><A
NAME="AEN157"
></A
><P
><B
>Example 2-1. Our first PHP script: <TT
CLASS="filename"
>hello.php</TT
></B
></P
><TABLE
BORDER="0"
BGCOLOR="#E0E0E0"
CELLPADDING="5"
><TR
><TD
><PRE
CLASS="php"
>&#60;html&#62;
 &#60;head&#62;
  &#60;title&#62;PHP Test&#60;/title&#62;
 &#60;/head&#62;
 &#60;body&#62;
 &#60;?php echo "&#60;p&#62;Hello World&#60;/p&#62;"; ?&#62;
 &#60;/body&#62;
&#60;/html&#62;</PRE
></TD
></TR
></TABLE
><P
>&#13;      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 <TT
CLASS="literal"
>http://localhost/hello.php</TT
> 
      or <TT
CLASS="literal"
>http://127.0.0.1/hello.php</TT
> but this depends on the
      web servers configuration.  Although this is outside the scope of this
      tutorial, see also the <TT
CLASS="varname"
>DocumentRoot</TT
> and
      <TT
CLASS="varname"
>ServerName</TT
> directives in your web servers
      configuration file. (on Apache this is <TT
CLASS="filename"
>httpd.conf</TT
>).
      If everything is setup correctly, this file will be parsed by PHP and
      the following output will make it to your browser:
     </P
><P
>&#13;      <TABLE
BORDER="0"
BGCOLOR="#E0E0E0"
CELLPADDING="5"
><TR
><TD
><PRE
CLASS="html"
>&#60;html&#62;
 &#60;head&#62;
  &#60;title&#62;PHP Test&#60;/title&#62;
 &#60;/head&#62;
 &#60;body&#62;
 &#60;p&#62;Hello World&#60;/p&#62;
 &#60;/body&#62;
&#60;/html&#62;</PRE
></TD
></TR
></TABLE
>
     </P
></DIV
></TD
></TR
></TABLE
>
   </P
><P
>&#13;    Note that this is not like a CGI script. The file does not need to be
    executable or special in any way. Think of it as a normal HTML
    file which happens to have a set of special tags available to you
    that do a lot of interesting things.
   </P
><P
>&#13;    This program is extremely simple and you really didn't need to use
    PHP to create a page like this. All it does is display:
    <TT
CLASS="literal"
>Hello World</TT
> using the PHP <A
HREF="function.echo.html"
><B
CLASS="function"
>echo()</B
></A
>
    statement.
   </P
><P
>&#13;    If you tried this example and it didn't output anything, or 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
    <A
HREF="installation.html"
>Installation</A
> chapter 
    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 <A
HREF="http://www.php.net/support.php"
TARGET="_top"
>PHP support</A
> options.
   </P
><P
>&#13;    The point of the example is to show the special PHP tag format.
    In this example we used <TT
CLASS="literal"
>&#60;?php</TT
> to indicate the
    start of a PHP tag. Then we put the PHP statement and left PHP mode by
    adding the closing tag, <TT
CLASS="literal"
>?&#62;</TT
>. You may jump in
    and out of PHP mode in an HTML file like this all you want.  For more
    details, read the manual section on <A
HREF="language.basic-syntax.html"
>&#13;    basic PHP syntax</A
>.
   </P
><DIV
CLASS="note"
><BLOCKQUOTE
CLASS="note"
><P
><B
>A Note on Text Editors: </B
>
     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 <A
HREF="http://phpeditors.dancinghippo.com/"
TARGET="_top"
>PHP Editor's
     List</A
>. 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.
    </P
></BLOCKQUOTE
></DIV
><DIV
CLASS="note"
><BLOCKQUOTE
CLASS="note"
><P
><B
>A Note on Word Processors: </B
>
     Word processors such as StarOffice Writer, Microsoft Word and Abiword are
     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.
    </P
></BLOCKQUOTE
></DIV
><DIV
CLASS="note"
><BLOCKQUOTE
CLASS="note"
><P
><B
>A Note on Windows Notepad: </B
>    
     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. "<TT
CLASS="filename"
>hello.php</TT
>").  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.
    </P
></BLOCKQUOTE
></DIV
><P
>&#13;   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
   <A
HREF="function.phpinfo.html"
><B
CLASS="function"
>phpinfo()</B
></A
> function and you'll see a lot of useful
   information about your system and setup such as available
   <A
HREF="language.variables.predefined.html"
>Predefined Variables</A
>, 
   loaded PHP modules, and <A
HREF="configuration.html"
>configuration</A
>
   settings.  Take some time and review this important information.
  </P
></DIV
><DIV
CLASS="NAVFOOTER"
><HR
ALIGN="LEFT"
WIDTH="100%"><TABLE
SUMMARY="Footer navigation table"
WIDTH="100%"
BORDER="0"
CELLPADDING="0"
CELLSPACING="0"
><TR
><TD
WIDTH="33%"
ALIGN="left"
VALIGN="top"
><A
HREF="tutorial.html"
ACCESSKEY="P"
>Prev</A
></TD
><TD
WIDTH="34%"
ALIGN="center"
VALIGN="top"
><A
HREF="index.html"
ACCESSKEY="H"
>Home</A
></TD
><TD
WIDTH="33%"
ALIGN="right"
VALIGN="top"
><A
HREF="tutorial.useful.html"
ACCESSKEY="N"
>Next</A
></TD
></TR
><TR
><TD
WIDTH="33%"
ALIGN="left"
VALIGN="top"
>A simple tutorial</TD
><TD
WIDTH="34%"
ALIGN="center"
VALIGN="top"
><A
HREF="tutorial.html"
ACCESSKEY="U"
>Up</A
></TD
><TD
WIDTH="33%"
ALIGN="right"
VALIGN="top"
>Something Useful</TD
></TR
></TABLE
></DIV
></BODY
></HTML
>