Sophie

Sophie

distrib > Mageia > 4 > x86_64 > by-pkgid > f800694edefe91adea2624f711a41a2d > files > 12457

php-manual-en-5.5.7-1.mga4.noarch.rpm

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
 <head>
  <meta http-equiv="content-type" content="text/html; charset=UTF-8">
  <title>Your first PHP-enabled page</title>

 </head>
 <body><div class="manualnavbar" style="text-align: center;">
 <div class="prev" style="text-align: left; float: left;"><a href="tutorial.requirements.html">What do I need?</a></div>
 <div class="next" style="text-align: right; float: right;"><a href="tutorial.useful.html">Something Useful</a></div>
 <div class="up"><a href="tutorial.html">A simple tutorial</a></div>
 <div class="home"><a href="index.html">PHP Manual</a></div>
</div><hr /><div id="tutorial.firstpage" class="section">
   <div class="info"><h1 class="title">Your first PHP-enabled page</h1></div>
   <p class="para">
    Create a file named <var class="filename">hello.php</var> and put it
    in your web server&#039;s root directory (<var class="varname"><var class="varname">DOCUMENT_ROOT</var></var>) 
    with the following content:
   </p>
   <p class="para">
    <div class="example" id="example-2">
     <div class="info"><p><strong>Example #1 Our first PHP script: <var class="filename">hello.php</var></strong></p></div>
     <div class="example-contents">
<div class="phpcode"><code><span style="color: #000000">
&lt;html&gt;<br />&nbsp;&lt;head&gt;<br />&nbsp;&nbsp;&lt;title&gt;PHP&nbsp;Test&lt;/title&gt;<br />&nbsp;&lt;/head&gt;<br />&nbsp;&lt;body&gt;<br />&nbsp;<span style="color: #0000BB">&lt;?php&nbsp;</span><span style="color: #007700">echo&nbsp;</span><span style="color: #DD0000">'&lt;p&gt;Hello&nbsp;World&lt;/p&gt;'</span><span style="color: #007700">;&nbsp;</span><span style="color: #0000BB">?&gt;</span>&nbsp;<br />&nbsp;&lt;/body&gt;<br />&lt;/html&gt;</span>
</code></div>
     </div>

     <div class="example-contents"><p>
      Use your browser to access the file with your web server&#039;s URL, ending
      with the <em>/hello.php</em> file reference. When developing locally this
      URL will be something like <em>http://localhost/hello.php</em> 
      or <em>http://127.0.0.1/hello.php</em> but this depends on the
      web server&#039;s configuration. If everything is configured correctly, this
      file will be parsed by PHP and the following output will be sent to
      your browser:
     </p></div>
     <div class="example-contents screen">
<div class="cdata"><pre>
&lt;html&gt;
 &lt;head&gt;
  &lt;title&gt;PHP Test&lt;/title&gt;
 &lt;/head&gt;
 &lt;body&gt;
 &lt;p&gt;Hello World&lt;/p&gt;
 &lt;/body&gt;
&lt;/html&gt;
</pre></div>
     </div>
    </div>
   </p>
   <p class="para">
    This program is extremely simple and you really did not need to use
    PHP to create a page like this. All it does is display:
    <em>Hello World</em> using the PHP  <span class="function"><a href="function.echo.html" class="function">echo</a></span>
    statement. Note that the file <em class="emphasis">does not need to be executable</em>
    or special in any way. The server finds out that this file needs to be interpreted
    by PHP because you used the &quot;.php&quot; extension, which the server is configured
    to pass on to PHP. Think of this 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 class="para">
    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, or is not configured properly.
    Ask your administrator to enable it for you using the
    <a href="install.html" class="link">Installation</a> chapter 
    of the manual. If you are developing locally, also read the
    installation chapter to make sure everything is configured
    properly. Make sure that you access the file via http with the server
    providing you the output. If you just call up the file from your file
    system, then it will not be parsed by PHP. If the problems persist anyway,
    do not hesitate to use one of the many
    <a href="http://www.php.net/support.php" class="link external">&raquo;&nbsp;PHP support</a> options.
   </p>
   <p class="para">
    The point of the example is to show the special PHP tag format.
    In this example we used <em>&lt;?php</em> to indicate the
    start of a PHP tag. Then we put the PHP statement and left PHP mode by
    adding the closing tag, <em>?&gt;</em>. You may jump in
    and out of PHP mode in an HTML file like this anywhere you want.  For more
    details, read the manual section on the <a href="language.basic-syntax.html" class="link">
    basic PHP syntax</a>.
   </p>
  
   <blockquote class="note"><p><strong class="note">Note</strong>: 
    <span class="info"><strong>A Note on Line Feeds</strong><br /></span>
    <p class="para">
     Line feeds have little meaning in HTML, however it is still a good idea
     to make your HTML look nice and clean by putting line feeds in.  A
     linefeed that follows immediately after a closing
     <em>?&gt;</em> will be removed by PHP.  This can be extremely
     useful when you are putting in many blocks of PHP or include files
     containing PHP that aren&#039;t supposed to output anything.  At the same time
     it can be a bit confusing.  You can put a space after the closing
     <em>?&gt;</em> to force a space and a line feed to be output,
     or you can put an explicit line feed in the last echo/print from within
     your PHP block.
    </p> 
   </p></blockquote> 

   <blockquote class="note"><p><strong class="note">Note</strong>: 
    <span class="info"><strong>A Note on Text Editors</strong><br /></span>
    <p class="para">
     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://en.wikipedia.org/wiki/List_of_PHP_editors" class="link external">&raquo;&nbsp;PHP Editors
     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>
   </p></blockquote>
   
   <blockquote class="note"><p><strong class="note">Note</strong>: 
    <span class="info"><strong>A Note on Word Processors</strong><br /></span>
    <p class="para">
     Word processors such as StarOffice Writer, Microsoft Word and Abiword are
     not optimal for editing PHP files.  If you wish to use one for this 
     test script, you must ensure that you save the file as <em class="emphasis">plain
     text</em> or PHP will not be able to read and execute the script.
    </p>
   </p></blockquote>
   
   <blockquote class="note"><p><strong class="note">Note</strong>: 
    <span class="info"><strong>A Note on Windows Notepad</strong><br /></span>
    <p class="para">
     If you are writing your PHP scripts using Windows Notepad, you will need
     to ensure that your files are saved with the <var class="filename">.php</var> extension.
     (Notepad adds a <var class="filename">.txt</var> 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. &quot;<var class="filename">hello.php</var>&quot;).  Alternatively, you can click on the 
     &#039;Text Documents&#039; drop-down menu in the &#039;Save&#039; dialog box and change the setting 
     to &quot;All Files&quot;. You can then enter your filename without quotes.
    </p>
   </p></blockquote>
  
   <p class="para">
    Now that you have successfully created a working PHP script, it is
    time to create the most famous PHP script!  Make a call to the
     <span class="function"><a href="function.phpinfo.html" class="function">phpinfo()</a></span> function and you will see a lot of useful
    information about your system and setup such as available
    <a href="language.variables.predefined.html" class="link">predefined variables</a>, 
    loaded PHP modules, and <a href="configuration.html" class="link">configuration</a>
    settings. Take some time and review this important information.
   </p>
   <p class="para">
    <div class="example" id="example-3">
     <div class="info"><p><strong>Example #2 Get system information from PHP</strong></p></div>
     <div class="example-contents">
<div class="phpcode"><code><span style="color: #000000">
<span style="color: #0000BB">&lt;?php&nbsp;phpinfo</span><span style="color: #007700">();&nbsp;</span><span style="color: #0000BB">?&gt;</span>
</span>
</code></div>
     </div>

    </div>
   </p>
  </div><hr /><div class="manualnavbar" style="text-align: center;">
 <div class="prev" style="text-align: left; float: left;"><a href="tutorial.requirements.html">What do I need?</a></div>
 <div class="next" style="text-align: right; float: right;"><a href="tutorial.useful.html">Something Useful</a></div>
 <div class="up"><a href="tutorial.html">A simple tutorial</a></div>
 <div class="home"><a href="index.html">PHP Manual</a></div>
</div></body></html>