mirror of
https://github.com/php/doc-it.git
synced 2026-03-26 00:22:14 +01:00
* Update oop5.xml * Update types.xml * Update fgetcsv.xml * Update bcdiv.xml * Update bcadd.xml and gmp-init.xml * Update ini.xml * Remove a file not in the EN tree * Fix credits section * Update get-magic-quotes-runtime.xml * Remove useless section * Update addslashes.xml * Update ini.core.xml * Update fwrite.xml * Remove ini.magic-quotes-gpc reference from language-snippets.ent * Update stripslashes.xml * Update parse-str.xml * Update oci-bind-by-name.xml
124 lines
3.3 KiB
XML
124 lines
3.3 KiB
XML
<?xml version="1.0" encoding="utf-8"?>
|
|
<!-- EN-Revision: 8cdc6621f9826d04abc3e50438c010804d7e8683 Maintainer: pastore Status: ready -->
|
|
<!-- CREDITS: darvina -->
|
|
<refentry xml:id="function.addslashes" xmlns="http://docbook.org/ns/docbook">
|
|
<refnamediv>
|
|
<refname>addslashes</refname>
|
|
<refpurpose>Esegue il quoting di una stringa con gli slash</refpurpose>
|
|
</refnamediv>
|
|
|
|
<refsect1 role="description">
|
|
&reftitle.description;
|
|
<methodsynopsis>
|
|
<type>string</type><methodname>addslashes</methodname>
|
|
<methodparam><type>string</type><parameter>string</parameter></methodparam>
|
|
</methodsynopsis>
|
|
<para>
|
|
La funzione restituisce una stringa con il carattere backslash anteposto ai caratteri
|
|
che richiedono l'escape. Questi caratteri sono:
|
|
<simplelist>
|
|
<member>virgoletta singola (<literal>'</literal>)</member>
|
|
<member>doppia virgoletta (<literal>"</literal>)</member>
|
|
<member>backslash (<literal>\</literal>)</member>
|
|
<member>NUL (il byte NUL)</member>
|
|
</simplelist>
|
|
</para>
|
|
<para>
|
|
Un caso d'uso di <function>addslashes</function> è fare l'escape dei suddetti
|
|
caratteri in una stringa che deve essere eseguita come script da PHP:
|
|
<informalexample>
|
|
<programlisting role="php">
|
|
<![CDATA[
|
|
<?php
|
|
$str = "O'Reilly?";
|
|
eval("echo '" . addslashes($str) . "';");
|
|
?>
|
|
]]>
|
|
</programlisting>
|
|
</informalexample>
|
|
</para>
|
|
<para>
|
|
A volte <function>addslashes</function> è erroneamente utilizzato per provare a prevenire
|
|
<link linkend="security.database.sql-injection">SQL Injection</link>. Invece,
|
|
dovrebbero essere usate funzioni di escape specifiche per il database e/o prepared statement.
|
|
</para>
|
|
</refsect1>
|
|
|
|
<refsect1 role="parameters">
|
|
&reftitle.parameters;
|
|
<para>
|
|
<variablelist>
|
|
<varlistentry>
|
|
<term><parameter>string</parameter></term>
|
|
<listitem>
|
|
<para>
|
|
La stringa su cui fare l'escape.
|
|
</para>
|
|
</listitem>
|
|
</varlistentry>
|
|
</variablelist>
|
|
</para>
|
|
</refsect1>
|
|
|
|
<refsect1 role="returnvalues">
|
|
&reftitle.returnvalues;
|
|
<para>
|
|
Restituisce la stringa trasformata dopo l'escape.
|
|
</para>
|
|
</refsect1>
|
|
|
|
<refsect1 role="examples">
|
|
&reftitle.examples;
|
|
<para>
|
|
<example>
|
|
<title>Un esempio di <function>addslashes</function></title>
|
|
<programlisting role="php">
|
|
<![CDATA[
|
|
<?php
|
|
$str = "Is your name O'Reilly?";
|
|
|
|
// Outputs: Is your name O\'Reilly?
|
|
echo addslashes($str);
|
|
?>
|
|
]]>
|
|
</programlisting>
|
|
</example>
|
|
</para>
|
|
</refsect1>
|
|
|
|
<refsect1 role="seealso">
|
|
&reftitle.seealso;
|
|
<para>
|
|
<simplelist>
|
|
<member><function>stripcslashes</function></member>
|
|
<member><function>stripslashes</function></member>
|
|
<member><function>addcslashes</function></member>
|
|
<member><function>htmlspecialchars</function></member>
|
|
<member><function>quotemeta</function></member>
|
|
<member><function>get_magic_quotes_gpc</function></member>
|
|
</simplelist>
|
|
</para>
|
|
</refsect1>
|
|
</refentry>
|
|
|
|
<!-- 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:"~/.phpdoc/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
|
|
-->
|