1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216
|
<?xml version="1.0" encoding="iso-8859-1"?>
<!-- EN-Revision: 1.19 Maintainer: perugini Status: ready -->
<chapter id="language.basic-syntax">
<title>Sintassi Fondamentale</title>
<!--
NOTE: Last modified: 2001-05-16 13:00 GMT
the language part is currently under heavy revision. Please do not
not make any heavy (i.e. structural) modifications to this part
for a moment.
You'd also better not start any translation yet.
Comments are always welcome at phpdoc@lists.php.net
Progress:
intro : DOESN'T EXIST - yet?
new chapter, with some introductionary remarks?
Will be discussed on the ML soon.
basic-syntax:
FINISHED
except maybe moving the 'advanced escaping'
to a better place?
TODO:
- nada
types : Being revised. Added all new types
Boolean and Integer are more or less finished.
The rest isn't.
TODO:
- why is $foo[bar] bad syntax?
- what's the difference between unset($bla) and
$bla = NULL; (it is different!)
- $obj->{expr} syntax
- (unset) cast?????
- $bla = unset <== should've been nuked, don't mention it
- $str{offset} syntax, rather than $str[offset]
- read notes and apply when any of them are useful
- remove notes which have been included here.
- ...
the rest: Not yet started with.
TODO:
- ?
oop : has been revised by Kristian, DONE.
-->
<sect1 id="language.basic-syntax.phpmode">
<title>Modi per uscire dalla modalit HTML</title>
<para>
Quando il PHP inizia a manipolare un file, produrr in uscita
solamente il testo che trova. Cos se si ha un file HTML, e si
modifica l'estensione in .php, il file continuer ad essere visibile.
</para>
<para>
Se si vogliono inserire delle istruzioni PHP in un certo punto
del file, occorre indicarlo al php, entrando nella "modalit PHP"
in uno dei seguenti modi:
</para>
<para>
<example>
<title>Metodi per uscire dalla modalit HTML</title>
<programlisting>
1. <? echo ("questo il pi semplice, ovvero come istruzione SGML\n"); ?>
<?= espressione ?> Questa un'abbreviazione per "<? echo espressione ?>"
2. <?php echo("se si vogliono produrre documenti XHTML o XML, si utilizzi questo modo\n"); ?>
3. <script language="php">
echo ("alcuni editor (tipo FrontPage) non
amano le istruzioni di elaborazione");
</script>
4. <% echo ("Opzionalmente puoi utilizzare tag nello stile ASP"); %>
<%= $variable; # Questo è una abbreviazione per "<%echo .." %>
</programlisting>
</example>
</para>
<para>
Il primo disponibile solo se sono stati abilitati
i tags abbreviati. Ci pu
essere impostato <!-- sia utilizzando la funzione <function>short_tags</function>, che-->
abilitando nel file di configurazione del PHP l'opzione
<link linkend="ini.short-open-tag">short_open_tag</link>, oppure compilando il PHP
utilizzando l'opzione --enable-short-tags nel comando <command>configure</command>.
</para>
<para>
Il secondo modo il metodo generalmente preferito, in quanto consente
alla prossima generazione di XHTML di essere facilmente implementato con il PHP.
</para>
<para>
Il quarto modo è disponibile solo se sono stati attivati nel file
di configurazione i tag in stile ASP tramite l'opzione
<link linkend="ini.asp-tags">asp_tags</link>.
<note>
<para>Il supporto per i tag nello stile ASP stato aggiunto nella versione 3.0.4.</para>
</note></para>
<para>
I tag di chiusura del blocco includono, se presente, il carattere
di newline immediatamente sucessivo.
</para>
<para> <!-- TODO: find a better place for this para -->
PHP allows you to use structures like this:
<example><title>Advanced escaping</title>
<programlisting role="php">
<?php
if (boolean-expression) {
?>
<strong>This is true.</strong>
<?php
} else {
?>
<strong>This is false.</strong>
<?php
}
?>
</programlisting></example>
This works as expected, because PHP handles text within ?> and
<?php as an <function>echo</function> statement.
<!-- without the parsing if vars, that is (hopefully?) obvious -->
</para>
</sect1>
<sect1 id="language.basic-syntax.instruction-separation">
<title>Separazione delle istruzioni</title>
<simpara>
Le istruzioni sono separate come nel C o in perl -
ogni istruzione termina con un punto e virgola.</simpara>
<para>
Il tag di chiusura (?>) implica anche la fine di un'istruzione,
perciò le seguenti sono equivalenti:
<informalexample>
<programlisting role="php">
<?php
echo "Questo ` un test";
?>
<?php echo "Questo ` un test" ?>
</programlisting>
</informalexample></para></sect1>
<sect1 id="language.basic-syntax.comments">
<title>Commenti</title>
<para>
PHP supporta i commenti dei linguaggi 'C', 'C++' e della shell Unix. Per esempio:
<informalexample><programlisting role="php">
<?php
echo "Questo ` un test"; // Questo è un commento su una linea nella stile c++
/* Questo è un commento su più linee
ancora un'altra linea di commento */
echo "Questo è un altro test";
echo "Un ultimo test"; # Questo è un commento stile shell Unix
?>
</programlisting>
</informalexample></para>
<simpara>
Lo stile di commento su "una linea", attualmente commenta solo fino alla fine della linea
o del blocco corrente di
codice PHP.</simpara>
<informalexample><programlisting role="php">
<h1>Questo è un <?# echo "semplice";?> esempio.</h1>
<p>L'intestazione qui sopra dirà 'Questo è un esempio'.
</programlisting></informalexample>
<simpara>
Occorre fare attenzione nel non annidare i commenti di stile C, situazione che si presenta
quando si commentano larghi blocchi di codice.</simpara>
<informalexample><programlisting role="php">
<?php
/*
echo "Questo è un test"; /* Questo commento causerà dei problemi */
*/
?>
</programlisting></informalexample></sect1>
</chapter>
<!-- Keep this comment at the end of the file
Local variables:
mode: sgml
sgml-omittag:t
sgml-shorttag:t
sgml-minimize-attributes:nil
sgml-always-quote-attributes:t
sgml-indent-step:1
sgml-indent-data:t
indent-tabs-mode:nil
sgml-parent-document:nil
sgml-default-dtd-file:"../../manual.ced"
sgml-exposed-tags:nil
sgml-local-catalogs:nil
sgml-local-ecat-files:nil
End:
vim600: syn=xml fen fdm=syntax fdl=2 si
vim: et tw=78 syn=sgml
vi: ts=1 sw=1
-->
|