<?php
include_once $_SERVER['DOCUMENT_ROOT'] . '/include/shared-manual.inc';
$TOC = array();
$TOC_DEPRECATED = array();
$PARENTS = array();
include_once dirname(__FILE__) ."/toc/features.commandline.inc";
$setup = array (
  'home' => 
  array (
    0 => 'index.php',
    1 => 'PHP Manual',
  ),
  'head' => 
  array (
    0 => 'UTF-8',
    1 => 'it',
  ),
  'this' => 
  array (
    0 => 'features.commandline.differences.php',
    1 => 'Differenze con gli altri SAPI',
    2 => 'Differenze con gli altri SAPI',
  ),
  'up' => 
  array (
    0 => 'features.commandline.php',
    1 => 'Command line usage',
  ),
  'prev' => 
  array (
    0 => 'features.commandline.introduction.php',
    1 => 'Introduzione',
  ),
  'next' => 
  array (
    0 => 'features.commandline.options.php',
    1 => 'Opzioni',
  ),
  'alternatives' => 
  array (
  ),
  'source' => 
  array (
    'lang' => 'it',
    'path' => 'features/commandline.xml',
  ),
  'history' => 
  array (
  ),
);
$setup["toc"] = $TOC;
$setup["toc_deprecated"] = $TOC_DEPRECATED;
$setup["parents"] = $PARENTS;
manual_setup($setup);

contributors($setup);

?>
<div id="features.commandline.differences" class="section">
  <h2 class="title">Differenze con gli altri <abbr title="Server Application Programming Interface">SAPI</abbr></h2>
  
  <p class="para">
   Le principali differenze tra la <abbr title="Command Line Interpreter/Interface">CLI</abbr> <abbr title="Server Application Programming Interface">SAPI</abbr> e le altre
   <abbr title="Server Application Programming Interface">SAPI</abbr> sono:
   <ul class="itemizedlist">
    <li class="listitem">
     <p class="para">
      A differenza di <abbr title="Common Gateway Interface">CGI</abbr> <abbr title="Server Application Programming Interface">SAPI</abbr>, non sono inviate in output
      delle intestazioni.
     </p>
     <p class="para">
      Mentre nella <abbr title="Common Gateway Interface">CGI</abbr> <abbr title="Server Application Programming Interface">SAPI</abbr> esiste un modo per sopprimere
      le intestazioni HTTP, nella <abbr title="Command Line Interpreter/Interface">CLI</abbr> <abbr title="Server Application Programming Interface">SAPI</abbr> non si ha una opzione
      per abilitare le intestazioni.
     </p>
     <p class="para">
      Per default <abbr title="Command Line Interpreter/Interface">CLI</abbr> parte in modalità silenziosa, si è mantenuto, comunque,
      l&#039;opzione <strong class="option unknown">-q</strong> e <strong class="option unknown">--no-header</strong> per motivi di compatibilità; 
      in questo modo si possono utlizzare i vecchi script <abbr title="Common Gateway Interface">CGI</abbr>.
     </p>
     <p class="para">
      Non cambia la directory di lavoro in quella dello script.
      (È rimasta l&#039;opzione <strong class="option unknown">-C</strong> e <strong class="option unknown">--no-chdir</strong> per
      compatibilità)
     </p>
     <p class="para">
      Messaggi di errore in formato testo (non formattati in <abbr title="Hyper Text Markup Language">HTML</abbr>).
     </p>
    </li>
    
    <li class="listitem">
     <p class="para">
      Esistono alcune direttive del <var class="filename">php.ini</var> che sono forzate nell&#039;impostazione dalla
      <abbr title="Command Line Interpreter/Interface">CLI</abbr> <abbr title="Server Application Programming Interface">SAPI</abbr> poiché non hanno senso nell&#039;ambiente di shell:
     </p>
     <p class="para">
      <table class="doctable table">
       <caption><strong>Direttive del <var class="filename">php.ini</var> forzate</strong></caption>
       
        <thead>
         <tr>
          <th>Direttiva</th>
          <th><abbr title="Command Line Interpreter/Interface">CLI</abbr> <abbr title="Server Application Programming Interface">SAPI</abbr> valore di default</th>
          <th>Commento</th>
         </tr>

        </thead>

        <tbody class="tbody">
         <tr>
          <td><a href="errorfunc.configuration.php#ini.html-errors" class="link">html_errors</a></td>
          <td><strong><code><a href="reserved.constants.php#constant.false">false</a></code></strong></td>
          <td>
           Il valore predefinito è <strong><code><a href="reserved.constants.php#constant.false">false</a></code></strong>, dato che è difficile leggere i messaggi di errore
           nell&#039;ambiente shell quando sono affogati in tag <abbr title="Hyper Text Markup Language">HTML</abbr>
           non interpretati.
          </td>
         </tr>

         <tr>
          <td><a href="outcontrol.configuration.php#ini.implicit-flush" class="link">implicit_flush</a></td>
          <td><strong><code><a href="reserved.constants.php#constant.true">true</a></code></strong></td>
          <td>
           In un ambiente shell, è desiderabile che ogni tipo di output proveniente da 
           <span class="function"><a href="function.print.php" class="function">print</a></span>, <span class="function"><a href="function.echo.php" class="function">echo</a></span> e simili sia scritto
           immediatamente e non venga bufferizzato.
           Tuttavia è ancora possibile utilizzare le funzioni di
           <a href="ref.outcontrol.php" class="link">buffering dell&#039;output</a>
           se si desidera ritardare o manipolare lo standard output.
          </td>
         </tr>

         <tr>
          <td><a href="info.configuration.php#ini.max-execution-time" class="link">max_execution_time</a></td>
          <td>0 (unlimited)</td>
          <td>
           PHP nell&#039;ambiente di shell tende ad essere utilizzato per una gamma di scopi molto
           diverso dalle applicazioni per il Web, e questi possono
           avere tempi di esecuzione molto lunghi; Il tempo massimo di esecuzione è impostato a infinito.
          </td>
         </tr>

         <tr>
          <td><a href="ini.core.php#ini.register-argc-argv" class="link">register_argc_argv</a></td>
          <td><strong><code><a href="reserved.constants.php#constant.true">true</a></code></strong></td>
          <td>
          <p class="para">
           Impostare questo parametro a <strong><code><a href="reserved.constants.php#constant.true">true</a></code></strong> significa che gli script eseguiti attraverso
           la <abbr title="Command Line Interpreter/Interface">CLI</abbr> <abbr>CLI SAPI</abbr> hanno sempre accesso a
           <em>argc</em> (numero di argomenti passati
           all&#039;applicazione) e <em>argv</em> (matrice degli
           argumenti).
          </p>
          <p class="para">
           Le variabili PHP <var class="varname"><a href="reserved.variables.argc.php" class="classname">$argc</a></var>
           e <var class="varname"><a href="reserved.variables.argv.php" class="classname">$argv</a></var> sono automaticamente impostate ai valori
           appropriati quando si usa la <abbr title="Command Line Interpreter/Interface">CLI</abbr> <abbr title="Server Application Programming Interface">SAPI</abbr>. Questi valori possono
           anche essere trovati nell&#039;array <var class="varname"><a href="reserved.variables.server.php" class="classname">$_SERVER</a></var>, per esempio: 
           <var class="varname"><a href="reserved.variables.server.php" class="classname">$_SERVER['argv']</a></var>
          </p>
          </td>
         </tr>

         <tr>
          <td><a href="outcontrol.configuration.php#ini.output-buffering" class="link">output_buffering</a></td>
          <td><strong><code><a href="reserved.constants.php#constant.false">false</a></code></strong></td>
          <td>
           <p class="para">
            Anche se il parametro nel <var class="filename">php.ini</var> è impostato a <strong><code><a href="reserved.constants.php#constant.false">false</a></code></strong>, le funzioni
            <a href="book.outcontrol.php" class="link">Output buffering</a>
            sono disponibili.
           </p>
          </td>
         </tr>

         <tr>
          <td><a href="info.configuration.php#ini.max-input-time" class="link">max_input_time</a></td>
          <td><strong><code><a href="reserved.constants.php#constant.false">false</a></code></strong></td>
          <td>
           <p class="para">
            La <abbr title="Command Line Interpreter/Interface">CLI</abbr> PHP non accetta GET, POST o upload di file.
           </p>
          </td>
         </tr>

        </tbody>
       
      </table>

     </p>
     <blockquote class="note"><p><strong class="note">Nota</strong>: 
      <p class="para">
       Queste direttive non possono essere inizializate con altri valori 
       dal file di configurazione  <var class="filename">php.ini</var> o da uno personalizzato (se specifictao). Questa è
       una limitazione perché questi valori di default sono applicati 
       dopo avere esaminato tutti i file di configurazione. Tuttavia i loro valori possono
       essere cambiati durante l&#039;esecuzione (operazione che non ha senso per queste direttive,
       ad esempio <a href="ini.core.php#ini.register-argc-argv" class="link">register_argc_argv</a>).
      </p>
     </p></blockquote>
     <blockquote class="note"><p><strong class="note">Nota</strong>: 
      <p class="para">
       It is recommended to set
       <a href="misc.configuration.php#ini.ignore-user-abort" class="link">ignore_user_abort</a> for
       command line scripts. See <span class="function"><a href="function.ignore-user-abort.php" class="function">ignore_user_abort()</a></span> for
       more information.
      </p>
     </p></blockquote>
    </li>
    
    <li class="listitem">
     <p class="para">
      Per potere lavorare meglio con le shell, sono state definite delle costanti
      per <a href="features.commandline.io-streams.php" class="link">gli stream I/O
      </a>.
     </p>
    </li>
    
    <li class="listitem">
     <p class="para">
      La <abbr title="Command Line Interpreter/Interface">CLI</abbr> <abbr title="Server Application Programming Interface">SAPI</abbr> <strong>non</strong> cambia la
      directory corrente in quella dello script eseguito!
     </p>
     <div class="example" id="example-1">
      <p><strong>Example #1 
       Il seguente esempio illustra la diferenza rispetto alla <abbr title="Common Gateway Interface">CGI</abbr>
       <abbr title="Server Application Programming Interface">SAPI</abbr>:
      </strong></p>
      <div class="example-contents">
<div class="phpcode"><code><span style="color: #000000"><span style="color: #0000BB">&lt;?php<br /></span><span style="color: #FF8000">// Semplice esempio di test chiamato test.php<br /></span><span style="color: #007700">echo </span><span style="color: #0000BB">getcwd</span><span style="color: #007700">(), </span><span style="color: #DD0000">"\n"</span><span style="color: #007700">;<br /></span><span style="color: #0000BB">?&gt;</span></span></code></div>
      </div>

      <div class="example-contents"><p>
       Quando si usa la versione <abbr title="Common Gateway Interface">CGI</abbr>, si avrà il seguente output:
      </p></div>
      <div class="example-contents screen">
<div class="cdata"><pre>
$ pwd
/tmp

$ php -q another_directory/test.php
/tmp/another_directory
</pre></div>
      </div>
      <div class="example-contents"><p>
       Questo evidenzia chiaramente come il PHP cambi la
       directory corrente con quella in cui si trova lo script.
      </p></div>
      <div class="example-contents"><p>
       Utilizzando la versione <abbr title="Command Line Interpreter/Interface">CLI</abbr> <abbr title="Server Application Programming Interface">SAPI</abbr> abbiamo:
      </p></div>
      <div class="example-contents screen">
<div class="cdata"><pre>
$ pwd
/tmp

$ php -f another_directory/test.php
/tmp
</pre></div>
      </div>
      <div class="example-contents"><p>
       Questo permette una grande flessibilità nello scrivere tools in PHP.
      </p></div>
     </div>
     <blockquote class="note"><p><strong class="note">Nota</strong>: 
      <p class="para">
       La <abbr title="Common Gateway Interface">CGI</abbr> <abbr title="Server Application Programming Interface">SAPI</abbr> supporta il comportamento 
       della <abbr title="Command Line Interpreter/Interface">CLI</abbr> <abbr title="Server Application Programming Interface">SAPI</abbr> attivando l&#039;opzione <strong class="option unknown">-C</strong>
       quando viene eseguito da linea di comando.
      </p>
     </p></blockquote>
    </li>
   </ul>
  </p>
 </div><?php manual_footer($setup); ?>