cvs: phpdoc-it /reference/classobj/functions class-exists.xml get-class-methods.xml get-class-vars.xml get-class.xml get-declared-classes.xml
get-object-vars.xml get-parent-class.xml is-subclass-of.xml method-exists.xml

From: Date: Thu, 05 May 2005 12:31:58 +0000
Subject: cvs: phpdoc-it /reference/classobj/functions class-exists.xml get-class-methods.xml get-class-vars.xml get-class.xml get-declared-classes.xml
get-object-vars.xml get-parent-class.xml is-subclass-of.xml method-exists.xml
Groups: php.doc.it 
Request: Send a blank email to doc-it+get-706@lists.php.net to get a copy of this message
darvina Thu May 5 08:31:58 2005 EDT Modified files: /phpdoc-it/reference/classobj/functions class-exists.xml get-class-methods.xml get-class-vars.xml get-class.xml get-declared-classes.xml get-object-vars.xml get-parent-class.xml is-subclass-of.xml method-exists.xml Log: Sync to En tree

http://cvs.php.net/diff.php/phpdoc-it/reference/classobj/functions/class-exists.xml?r1=1.4&r2=1.5&ty=u Index: phpdoc-it/reference/classobj/functions/class-exists.xml diff -u phpdoc-it/reference/classobj/functions/class-exists.xml:1.4 phpdoc-it/reference/classobj/functions/class-exists.xml:1.5 --- phpdoc-it/reference/classobj/functions/class-exists.xml:1.4 Mon Aug 9 08:01:46 2004 +++ phpdoc-it/reference/classobj/functions/class-exists.xml Thu May 5 08:31:57 2005 @@ -1,8 +1,6 @@ <?xml version="1.0" encoding="iso-8859-1"?> <!-- splitted from ./it/functions/classobj.xml, last change in rev 1.1 --> -<!-- last change to 'class-exists' in en/ tree in rev 1.11 --> -<!-- EN-Revision: 1.5 Maintainer: darvina Status: ready --> -<!-- OLD-Revision: 1.38/EN.1.11 --> +<!-- EN-Revision: 1.6 Maintainer: darvina Status: ready --> <refentry id="function.class-exists"> <refnamediv> <refname>class_exists</refname> @@ -10,22 +8,33 @@ </refnamediv> <refsect1> <title>Descrizione</title> - <methodsynopsis> - <type>bool</type><methodname>class_exists</methodname> - <methodparam><type>string</type><parameter>nome_classe</parameter></methodparam> - <methodparam choice="opt"><type>bool</type><parameter>autoload</parameter></methodparam> - </methodsynopsis> - <note> - <para> - Il parametro <parameter>autoload</parameter> è stato aggiunto in PHP 5 - </para> - </note> + <methodsynopsis> + <type>bool</type><methodname>class_exists</methodname> + <methodparam><type>string</type><parameter>nome_classe</parameter></methodparam> + <methodparam choice="opt"><type>bool</type><parameter>autoload</parameter></methodparam> + </methodsynopsis> <para> Questa funzione restituisce &true; se la classe indicata dal parametro <parameter>nome_classe</parameter> è stata definita, altrimenti restituisce &false; . </para> <para> + <example> + <title>Esempio di uso di <function>class_exists</function></title> + <programlisting role="php"> +<![CDATA[ +<?php +// Verifica se la classe esiste prima di richiamarla +if (class_exists('MyClass')) { + $myclass = new MyClass(); +} + +?> +]]> + </programlisting> + </example> + </para> + <para> <function>class_exists</function>, per default, tenta di eseguire __autoload, se non si desidera che <function>class_exists</function> esegua __autoload(), impostare il parametro <parameter>autoload</parameter> @@ -37,26 +46,33 @@ <programlisting role="php"> <![CDATA[ <?php - function __autoload($class) { - include($class . '.php'); - - /* Check to see it the include defined the class */ - if ( !class_exists($class, false) ) { - trigger_error("Unable to load class $class", E_USER_ERROR); - } - } +function __autoload($class) +{ + include($class . '.php'); + // Check to see it the include defined the class + if ( !class_exists($class, false) ) { + trigger_error("Unable to load class $class", E_USER_ERROR); + } + +} - if( class_exists('MyClass') ) { - $myclass = new MyClass(); - } +if( class_exists('MyClass') ) { + $myclass = new MyClass(); +} ?> ]]> </programlisting> </example> </para> + <note> + <para> + Il parametro <parameter>autoload</parameter> è stato aggiunto in PHP 5 + </para> + </note> <simpara> - Vedere anche <function>get_declared_classes</function>. + Vedere anche <function>interface_exists</function> + e <function>get_declared_classes</function>. </simpara> </refsect1> </refentry> http://cvs.php.net/diff.php/phpdoc-it/reference/classobj/functions/get-class-methods.xml?r1=1.6&r2=1.7&ty=u Index: phpdoc-it/reference/classobj/functions/get-class-methods.xml diff -u phpdoc-it/reference/classobj/functions/get-class-methods.xml:1.6 phpdoc-it/reference/classobj/functions/get-class-methods.xml:1.7 --- phpdoc-it/reference/classobj/functions/get-class-methods.xml:1.6 Sun Apr 4 15:44:35 2004 +++ phpdoc-it/reference/classobj/functions/get-class-methods.xml Thu May 5 08:31:57 2005 @@ -1,5 +1,5 @@ <?xml version="1.0" encoding="iso-8859-1"?> -<!-- EN-Revision: 1.7 Maintainer: darvina Status: ready --> +<!-- EN-Revision: 1.9 Maintainer: darvina Status: ready --> <refentry id="function.get-class-methods"> <refnamediv> <refname>get_class_methods</refname> @@ -68,9 +68,7 @@ ?> ]]> </programlisting> - <para> - Produrrà: - </para> + &example.outputs; <screen> <![CDATA[ miaclasse @@ -80,6 +78,12 @@ </screen> </example> </para> + <warning> + <para> + Dal PHP 5, questa funzione restituisce il nome dei metodi così come sono + dichiarati (sensibile alle maiuscole). In PHP 4 erano restituiti in minuscolo. + </para> + </warning> <simpara> Vedere anche <function>get_class_vars</function> e <function>get_object_vars</function> http://cvs.php.net/diff.php/phpdoc-it/reference/classobj/functions/get-class-vars.xml?r1=1.7&r2=1.8&ty=u Index: phpdoc-it/reference/classobj/functions/get-class-vars.xml diff -u phpdoc-it/reference/classobj/functions/get-class-vars.xml:1.7 phpdoc-it/reference/classobj/functions/get-class-vars.xml:1.8 --- phpdoc-it/reference/classobj/functions/get-class-vars.xml:1.7 Sun Apr 4 15:44:35 2004 +++ phpdoc-it/reference/classobj/functions/get-class-vars.xml Thu May 5 08:31:57 2005 @@ -1,7 +1,7 @@ <?xml version="1.0" encoding="iso-8859-1"?> <!-- splitted from ./it/functions/classobj.xml, last change in rev 1.3 --> <!-- last change to 'get-class-vars' in en/ tree in rev 1.1 --> -<!-- EN-Revision: 1.7 Maintainer: darvina Status: ready --> +<!-- EN-Revision: 1.9 Maintainer: darvina Status: ready --> <!-- OLD-Revision: 1.38/EN.1.1 --> <refentry id="function.get-class-vars"> <refnamediv> @@ -18,7 +18,7 @@ </methodsynopsis> <para> Questa funzione restituisce un array associativo contenente - le proprietà di default della classe. Gli elementi dell'array + le proprietà di default pubbliche della classe. Gli elementi dell'array prodotto sono nel formato <parameter>nomevariabile => valore</parameter>. </para> <note> @@ -39,7 +39,7 @@ var $var1; // questa variabile non ha un valore di default... var $var2 = "xyz"; var $var3 = 100; - + private $var4; // PHP 5 // costruttore function miaclasse() { // Modifico qualche proprietà @@ -61,9 +61,7 @@ ?> ]]> </programlisting> - <para> - Produrrà: - </para> + &example.outputs; <screen> <![CDATA[ // Versioni di PHP antecedenti alla 4.2.0 http://cvs.php.net/diff.php/phpdoc-it/reference/classobj/functions/get-class.xml?r1=1.5&r2=1.6&ty=u Index: phpdoc-it/reference/classobj/functions/get-class.xml diff -u phpdoc-it/reference/classobj/functions/get-class.xml:1.5 phpdoc-it/reference/classobj/functions/get-class.xml:1.6 --- phpdoc-it/reference/classobj/functions/get-class.xml:1.5 Fri May 28 16:20:36 2004 +++ phpdoc-it/reference/classobj/functions/get-class.xml Thu May 5 08:31:57 2005 @@ -1,7 +1,7 @@ <?xml version="1.0" encoding="iso-8859-1"?> <!-- splitted from ./it/functions/classobj.xml, last change in rev 1.1 --> <!-- last change to 'get-class' in en/ tree in rev 1.4 --> -<!-- EN-Revision: 1.6 Maintainer: darvina Status: ready --> +<!-- EN-Revision: 1.7 Maintainer: darvina Status: ready --> <!-- OLD-Revision: 1.38/EN.1.4 --> <refentry id="function.get-class"> <refnamediv> @@ -58,9 +58,7 @@ ?> ]]> </programlisting> - <para> - L'esempio precedente visualizzerà: - </para> + &example.outputs; <screen> <![CDATA[ Il suo nome è: foo http://cvs.php.net/diff.php/phpdoc-it/reference/classobj/functions/get-declared-classes.xml?r1=1.4&r2=1.5&ty=u Index: phpdoc-it/reference/classobj/functions/get-declared-classes.xml diff -u phpdoc-it/reference/classobj/functions/get-declared-classes.xml:1.4 phpdoc-it/reference/classobj/functions/get-declared-classes.xml:1.5 --- phpdoc-it/reference/classobj/functions/get-declared-classes.xml:1.4 Thu Jun 10 08:24:27 2004 +++ phpdoc-it/reference/classobj/functions/get-declared-classes.xml Thu May 5 08:31:57 2005 @@ -1,7 +1,7 @@ <?xml version="1.0" encoding="iso-8859-1"?> <!-- splitted from ./it/functions/classobj.xml, last change in rev 1.1 --> <!-- last change to 'get-declared-classes' in en/ tree in rev 1.11 --> -<!-- EN-Revision: 1.5 Maintainer: darvina Status: ready --> +<!-- EN-Revision: 1.6 Maintainer: darvina Status: ready --> <!-- OLD-Revision: 1.38/EN.1.11 --> <refentry id="function.get-declared-classes"> <refnamediv> @@ -47,9 +47,7 @@ ?> ]]> </programlisting> - <para> - Questo esempio visualizzerà qualcosa simile a: - </para> + &example.outputs.similar; <screen> <![CDATA[ Array http://cvs.php.net/diff.php/phpdoc-it/reference/classobj/functions/get-object-vars.xml?r1=1.6&r2=1.7&ty=u Index: phpdoc-it/reference/classobj/functions/get-object-vars.xml diff -u phpdoc-it/reference/classobj/functions/get-object-vars.xml:1.6 phpdoc-it/reference/classobj/functions/get-object-vars.xml:1.7 --- phpdoc-it/reference/classobj/functions/get-object-vars.xml:1.6 Thu Jun 10 08:24:27 2004 +++ phpdoc-it/reference/classobj/functions/get-object-vars.xml Thu May 5 08:31:57 2005 @@ -1,7 +1,7 @@ <?xml version="1.0" encoding="iso-8859-1"?> <!-- splitted from ./it/functions/classobj.xml, last change in rev 1.3 --> <!-- last change to 'get-object-vars' in en/ tree in rev 1.1 --> -<!-- EN-Revision: 1.7 Maintainer: darvina Status: ready --> +<!-- EN-Revision: 1.8 Maintainer: darvina Status: ready --> <!-- OLD-Revision: 1.38/EN.1.1 --> <refentry id="function.get-object-vars"> <refnamediv> @@ -66,9 +66,7 @@ ?> ]]> </programlisting> - <para> - L'output del programma precedente sarà: - </para> + &example.outputs; <screen> <![CDATA[ Array http://cvs.php.net/diff.php/phpdoc-it/reference/classobj/functions/get-parent-class.xml?r1=1.4&r2=1.5&ty=u Index: phpdoc-it/reference/classobj/functions/get-parent-class.xml diff -u phpdoc-it/reference/classobj/functions/get-parent-class.xml:1.4 phpdoc-it/reference/classobj/functions/get-parent-class.xml:1.5 --- phpdoc-it/reference/classobj/functions/get-parent-class.xml:1.4 Sun Apr 4 15:44:35 2004 +++ phpdoc-it/reference/classobj/functions/get-parent-class.xml Thu May 5 08:31:57 2005 @@ -1,7 +1,7 @@ <?xml version="1.0" encoding="iso-8859-1"?> <!-- splitted from ./it/functions/classobj.xml, last change in rev 1.3 --> <!-- last change to 'get-parent-class' in en/ tree in rev 1.4 --> -<!-- EN-Revision: 1.5 Maintainer: darvina Status: ready --> +<!-- EN-Revision: 1.6 Maintainer: darvina Status: ready --> <!-- OLD-Revision: 1.38/EN.1.4 --> <refentry id="function.get-parent-class"> <refnamediv> @@ -58,9 +58,7 @@ ?> ]]> </programlisting> - <para> - L'esempio visualizzerà: - </para> + &example.outputs; <screen> <![CDATA[ Io sono figlio di dad http://cvs.php.net/diff.php/phpdoc-it/reference/classobj/functions/is-subclass-of.xml?r1=1.4&r2=1.5&ty=u Index: phpdoc-it/reference/classobj/functions/is-subclass-of.xml diff -u phpdoc-it/reference/classobj/functions/is-subclass-of.xml:1.4 phpdoc-it/reference/classobj/functions/is-subclass-of.xml:1.5 --- phpdoc-it/reference/classobj/functions/is-subclass-of.xml:1.4 Mon Aug 9 08:01:46 2004 +++ phpdoc-it/reference/classobj/functions/is-subclass-of.xml Thu May 5 08:31:57 2005 @@ -1,7 +1,7 @@ <?xml version="1.0" encoding="iso-8859-1"?> <!-- splitted from ./it/functions/classobj.xml, last change in rev 1.9 --> <!-- last change to 'is-subclass-of' in en/ tree in rev 1.4 --> -<!-- EN-Revision: 1.4 Maintainer: darvina Status: ready --> +<!-- EN-Revision: 1.5 Maintainer: darvina Status: ready --> <!-- OLD-Revision: 1.38/EN.1.4 --> <refentry id="function.is-subclass-of"> <refnamediv> @@ -14,13 +14,19 @@ <title>Descrizione</title> <methodsynopsis> <type>bool</type><methodname>is_subclass_of</methodname> - <methodparam><type>object</type><parameter>oggetto</parameter></methodparam> + <methodparam><type>mixed</type><parameter>oggetto</parameter></methodparam> <methodparam><type>string</type><parameter>nome_classe</parameter></methodparam> </methodsynopsis> <para> Questa funzione restituisce &true; se <parameter>obj</parameter>, appartiene ad una sottoclasse di <parameter>nome_classe</parameter>, altrimenti &false;. </para> + <note> + <para> + Dal PHP 5.0.3 si può specificare il parametro <parameter>oggetto</parameter> + come stringa (il nome della classe). + </para> + </note> <para> <example> <title>Esempio di uso di <function>is_subclass_of</function></title> @@ -48,18 +54,30 @@ } else { echo "no, \$WFC is not a subclass of WidgetFactory\n"; } -// Visualizza "yes, $WFC is a subclass of WidgetFactory\n" (sì, $WFC è una sottoclasse di WidgetFactory\n); if (is_subclass_of($WF, 'WidgetFactory')) { echo "yes, \$WF is a subclass of WidgetFactory\n"; } else { echo "no, \$WF is not a subclass of WidgetFactory\n"; } -// Visualizza "no, $WF is not a subclass of WidgetFactory\n" (no, $WF non è una sottoclasse di WidgetFactory\n) +// utilizzabile dal PHP 5.0.3 +if (is_subclass_of('WidgetFactory_Child', 'WidgetFactory')) { + echo "yes, WidgetFactory_Child is a subclass of WidgetFactory\n"; +} else { + echo "no, WidgetFactory_Child is not a subclass of WidgetFactory\n"; +} ?> ]]> </programlisting> - </example> + &example.outputs; + <screen> +<![CDATA[ +yes, $WFC is a subclass of WidgetFactory +no, $WF is not a subclass of WidgetFactory +yes, WidgetFactory_Child is a subclass of WidgetFactory +]]> + </screen> + </example> </para> <simpara> Vedere anche <function>get_class</function>, http://cvs.php.net/diff.php/phpdoc-it/reference/classobj/functions/method-exists.xml?r1=1.3&r2=1.4&ty=u Index: phpdoc-it/reference/classobj/functions/method-exists.xml diff -u phpdoc-it/reference/classobj/functions/method-exists.xml:1.3 phpdoc-it/reference/classobj/functions/method-exists.xml:1.4 --- phpdoc-it/reference/classobj/functions/method-exists.xml:1.3 Thu Jun 10 08:24:27 2004 +++ phpdoc-it/reference/classobj/functions/method-exists.xml Thu May 5 08:31:57 2005 @@ -1,7 +1,7 @@ <?xml version="1.0" encoding="iso-8859-1"?> <!-- splitted from ./it/functions/classobj.xml, last change in rev 1.5 --> <!-- last change to 'method-exists' in en/ tree in rev 1.9 --> -<!-- EN-Revision: 1.3 Maintainer: darvina Status: ready --> +<!-- EN-Revision: 1.4 Maintainer: darvina Status: ready --> <!-- OLD-Revision: 1.38/EN.1.9 --> <refentry id="function.method-exists"> <refnamediv> @@ -31,9 +31,7 @@ ?> ]]> </programlisting> - <para> - Questo script visualizzerà : - </para> + &example.outputs; <screen> <![CDATA[ bool(true)
« previous php.doc.it (#706) next »