<?php
include_once $_SERVER['DOCUMENT_ROOT'] . '/include/shared-manual.inc';
$TOC = array();
$TOC_DEPRECATED = array();
$PARENTS = array();
include_once dirname(__FILE__) ."/toc/getting-started.inc";
$setup = array (
  'home' => 
  array (
    0 => 'index.php',
    1 => 'PHP Manual',
  ),
  'head' => 
  array (
    0 => 'UTF-8',
    1 => 'en',
  ),
  'this' => 
  array (
    0 => 'introduction.php',
    1 => 'Introduction',
    2 => 'What is PHP and what can it do?',
  ),
  'up' => 
  array (
    0 => 'getting-started.php',
    1 => 'Getting Started',
  ),
  'prev' => 
  array (
    0 => 'getting-started.php',
    1 => 'Getting Started',
  ),
  'next' => 
  array (
    0 => 'tutorial.php',
    1 => 'A simple tutorial',
  ),
  'alternatives' => 
  array (
  ),
  'source' => 
  array (
    'lang' => 'en',
    'path' => 'chapters/intro.xml',
  ),
  'history' => 
  array (
  ),
);
$setup["toc"] = $TOC;
$setup["toc_deprecated"] = $TOC_DEPRECATED;
$setup["parents"] = $PARENTS;
manual_setup($setup);

contributors($setup);

?>
<div id="introduction" class="chapter">
  <div class="info">
   
   <h1 class="title">What is PHP and what can it do?</h1>

  </div>

  <div id="intro-whatis" class="section">
   <div class="info"><h1 class="title">What is PHP?</h1></div>
   <p class="para">
    <abbr title="PHP: Hypertext Preprocessor">PHP</abbr> (recursive acronym for <em>PHP: Hypertext
    Preprocessor</em>) is a widely-used open source general-purpose
    scripting language that is especially suited for web
    development and can be embedded into HTML.
   </p>
   <p class="para">
    Nice, but what does that mean? An example:
   </p>
   <p class="para">
    <div class="example" id="example-1">
     <div class="info"><p><strong>Example #1 An introductory example</strong></p></div>
     <div class="example-contents">
<div class="phpcode"><code><span style="color: #000000">&lt;!DOCTYPE html&gt;<br />&lt;html&gt;<br />    &lt;head&gt;<br />        &lt;title&gt;Example&lt;/title&gt;<br />    &lt;/head&gt;<br />    &lt;body&gt;<br /><br />        <span style="color: #0000BB">&lt;?php<br />            </span><span style="color: #007700">echo </span><span style="color: #DD0000">"Hi, I'm a PHP script!"</span><span style="color: #007700">;<br />        </span><span style="color: #0000BB">?&gt;<br /></span><br />    &lt;/body&gt;<br />&lt;/html&gt;</span></code></div>
     </div>

    </div>
   </p>
   <p class="para">
    Instead of lots of commands to output HTML (as seen in C or Perl),
    PHP pages contain HTML with embedded code that does
    <span class="replaceable">something</span> (in this case, output <span class="computeroutput">Hi, I&#039;m a PHP script!</span>).
    The PHP code is enclosed in special <a href="language.basic-syntax.phpmode.php" class="link">start and end processing
    instructions <code class="code">&lt;?php</code> and <code class="code">?&gt;</code></a>
    that allow jumping in and out of <q class="quote">PHP mode.</q>
   </p>
   <p class="para">
    What distinguishes PHP from something like client-side JavaScript
    is that the code is executed on the server, generating HTML which
    is then sent to the client. The client would receive
    the results of running that script, but would not know
    what the underlying code was. A web server can even be configured
    to process all HTML files with PHP, and then there&#039;s no
    way that users can tell that PHP is being used.
   </p>
   <p class="para">
    The best part about using PHP is that it is extremely simple
    for a newcomer, but offers many advanced features for
    a professional programmer. Don&#039;t be afraid to read the long
    list of PHP&#039;s features. With PHP, almost anyone can get up and running and be
    writing simple scripts in no time at all.
   </p>
   <p class="para">
    Although PHP&#039;s development is focused on server-side scripting,
    much more can be done with it. Read on, and see more in the
    <a href="introduction.php#intro-whatcando" class="link">What can PHP do?</a> section,
    or go right to the <a href="tutorial.php" class="link">introductory
    tutorial</a> to jump straight to learning about web programming.
   </p>
  </div>

  <div id="intro-whatcando" class="section">
   <div class="info"><h1 class="title">What can PHP do?</h1></div>
   <p class="para">
    Anything. PHP is mainly focused on server-side scripting,
    so it can do anything any other CGI program can do, such
    as collect form data, generate dynamic page content, or
    send and receive cookies. But PHP can do much more.
   </p>
   <p class="para">
    There are two main areas where PHP scripts are used.
    <ul class="itemizedlist">
     <li class="listitem">
      <span class="simpara">
       Server-side scripting. This is the most widely used
       and main target field for PHP. Three things are needed
       to make this work: the PHP parser (CGI or server
       module), a web server, and a web browser. All these can
       run on a local machine in order to just experiment
       with PHP programming. See the
       <a href="install.php" class="link">installation instructions</a>
       section for more information.
      </span>
     </li>
     <li class="listitem">
      <span class="simpara">
       Command line scripting. A PHP script can be run
       without any server or browser, only the
       PHP parser is needed to use it this way.
       This type of usage is ideal for scripts regularly
       executed using <strong class="command">cron</strong> (on Unix or macOS) or Task Scheduler (on
       Windows). These scripts can also be used for simple text
       processing tasks. See the section about
       <a href="features.commandline.php" class="link">Command line usage of PHP</a>
       for more information.
      </span>
     </li>
    </ul>
   </p>
   <p class="para">
    PHP can be <a href="install.php" class="link">used</a> on all major operating systems, including
    Linux, many Unix variants (including HP-UX, Solaris and OpenBSD),
    Microsoft Windows, macOS, RISC OS, and probably others.
    PHP also has support for most of the web servers today. This
    includes Apache, IIS, and many others. And this includes any
    web server that can utilize the FastCGI PHP binary, like lighttpd
    and nginx. PHP works as either a module, or as a CGI processor.
   </p>
   <p class="para">
    So with PHP, developers have the freedom of choosing an operating
    system and a web server. Furthermore, they also have the choice
    of using procedural programming or object-oriented
    programming (OOP), or a mixture of them both.
   </p>
   <p class="para">
    PHP is not limited to outputting HTML. PHP&#039;s abilities include
    outputting rich file types, such as images or PDF files, encrypting data,
    and sending emails. It can also output easily any text, such as JSON
    or XML. PHP can autogenerate these files, and save them in the
    file system, instead of printing it out, forming a server-side cache for
    dynamic content.
   </p>
   <p class="para">
    One of the strongest and most significant features in PHP is its
    support for a <a href="refs.database.php" class="link">wide range of databases</a>. 
    Writing a database-enabled web page is incredibly simple using one of
    the database specific extensions (e.g., for <a href="book.mysqli.php" class="link">mysql</a>),
    or using an abstraction layer like <a href="book.pdo.php" class="link">PDO</a>, or connect
    to any database supporting the Open Database Connection standard via the
    <a href="book.uodbc.php" class="link">ODBC</a> extension. Other databases may utilize
    <a href="book.curl.php" class="link">cURL</a> or <a href="book.sockets.php" class="link">sockets</a>,
    like CouchDB.
   </p>
   <p class="para">
    PHP also has support for talking to other services using protocols
    such as LDAP, IMAP, SNMP, NNTP, POP3, HTTP, COM (on Windows) and
    countless others. It can also open raw network sockets and
    interact using any other protocol. PHP has support for the WDDX
    complex data exchange between virtually all Web programming
    languages. Talking about interconnection, PHP has support for
    instantiation of Java objects and using them transparently
    as PHP objects.
   </p>
   <p class="para">
    PHP has useful <a href="refs.basic.text.php" class="link">text processing</a> features,
    which includes the Perl compatible regular expressions (<a href="book.pcre.php" class="link">PCRE</a>),
    and many extensions and tools to <a href="refs.xml.php" class="link">parse and access XML documents</a>.
    PHP standardizes all of the XML extensions on the solid base of <a href="book.libxml.php" class="link">libxml2</a>,
    and extends the feature set adding <a href="book.simplexml.php" class="link">SimpleXML</a>,
    <a href="book.xmlreader.php" class="link">XMLReader</a> and <a href="book.xmlwriter.php" class="link">XMLWriter</a> support.
   </p>
   <p class="para">
    And many other interesting extensions exist, which are categorized both
    <a href="extensions.php" class="link">alphabetically</a> and by <a href="funcref.php" class="link">category</a>.
    And there are additional <a href="install.pecl.intro.php" class="link">PECL extensions</a> that may or may not be documented
    within the PHP manual itself, like <a href="http://xdebug.org/" class="link external">&raquo;&nbsp;XDebug</a>.
   </p>
   <p class="para">
    This page is not enough to list all
    the features and benefits PHP can offer. Read on in
    the sections about <a href="install.php" class="link">installing
    PHP</a>, and see the <a href="funcref.php" class="link">function
    reference</a> part for explanation of the extensions
    mentioned here.
   </p>
  </div>

 </div>
<?php manual_footer($setup); ?>