<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Ciarpame {.com} &#187; autoloading</title>
	<atom:link href="http://www.ciarpame.com/tag/autoloading/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.ciarpame.com</link>
	<description>Useful stuffs for the masses. Useless things for few.</description>
	<lastBuildDate>Tue, 01 Dec 2009 13:03:55 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.4-alpha</generator>
		<item>
		<title>La funzione __autoload di PHP</title>
		<link>http://www.ciarpame.com/2009/12/01/la-funzione-__autoload-di-php/</link>
		<comments>http://www.ciarpame.com/2009/12/01/la-funzione-__autoload-di-php/#comments</comments>
		<pubDate>Tue, 01 Dec 2009 12:54:41 +0000</pubDate>
		<dc:creator>Mattia Palugan</dc:creator>
				<category><![CDATA[Programming]]></category>
		<category><![CDATA[autoloading]]></category>
		<category><![CDATA[classes]]></category>
		<category><![CDATA[oop]]></category>
		<category><![CDATA[PHP]]></category>

		<guid isPermaLink="false">http://www.ciarpame.com/?p=667</guid>
		<description><![CDATA[La funzione __autoload di PHP è una funzione molto utile per includere delle classi solo quando servono e senza doverle includere a mano. Se esiste, questa funzione, infatti, viene richiamata quando si tenta di utilizzare una classe o un&#8217;interfaccia che non è stata ancora dichiarata. Ha un unico parametro che è il nome della classe [...]]]></description>
			<content:encoded><![CDATA[<p>La funzione <a title="PHP: Autoloading Classes" href="http://www.php.net/autoload">__autoload</a> di PHP è una funzione molto utile per includere delle classi solo quando servono e senza doverle includere a mano.<br />
<span id="more-667"></span><br />
Se esiste, questa funzione, infatti, viene richiamata quando si tenta di utilizzare una classe o un&#8217;interfaccia che non è stata ancora dichiarata.<br />
Ha un unico parametro che è il nome della classe che è possibile manipolare per arrivare al nome del file che la include e non restituisce nulla.<br />
Ecco un esempio dove le classi sono contenute in una cartella con il percorso definito nella costante <em>_CLASS</em> e in file con il nome “nomeclasse.class.php”:</p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">&lt;?php</span>
<span style="color: #009933; font-style: italic;">/**
* Autoload delle classi
* @param string $c nome della classe
*/</span>
<span style="color: #000000; font-weight: bold;">function</span> __autoload<span style="color: #009900;">&#40;</span><span style="color: #000088;">$class_name</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
	<span style="color: #000088;">$path</span> <span style="color: #339933;">=</span>  _CLASS<span style="color: #339933;">.</span><span style="color: #990000;">strtolower</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$class_name</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">.</span><span style="color: #0000ff;">'.class.php'</span><span style="color: #339933;">;</span>
	<span style="color: #b1b100;">if</span><span style="color: #009900;">&#40;</span><span style="color: #990000;">file_exists</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$path</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
		<span style="color: #b1b100;">require_once</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$path</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
	<span style="color: #009900;">&#125;</span>
	<span style="color: #990000;">unset</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$path</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span>
<span style="color: #000000; font-weight: bold;">?&gt;</span></pre></div></div>

]]></content:encoded>
			<wfw:commentRss>http://www.ciarpame.com/2009/12/01/la-funzione-__autoload-di-php/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

