<?xml 
version="1.0" encoding="utf-8"?>
<rss version="2.0" 
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
>

<channel xml:lang="fr">
	<title>6blog</title>
	<link>http://blog.6tech.net/</link>
	
	<language>fr</language>
	<generator>SPIP - www.spip.net</generator>

	<image>
		<title>6blog</title>
		<url>http://blog.6tech.net/IMG/siteon0.jpg</url>
		<link>http://blog.6tech.net/</link>
		<height>32</height>
		<width>144</width>
	</image>



<item xml:lang="fr">
		<title>Cut a file on specified lines</title>
		<link>http://blog.6tech.net/Cut-a-file-on-specified-lines,45.html</link>
		<guid isPermaLink="true">http://blog.6tech.net/Cut-a-file-on-specified-lines,45.html</guid>
		<dc:date>2011-08-12T13:14:53Z</dc:date>
		<dc:format>text/html</dc:format>
		<dc:language>fr</dc:language>
		<dc:creator>Domenjoud Yannick</dc:creator>


		<dc:subject>BASH</dc:subject>

		<description>I tried to look on a script/cmd which allow me to cut a file into several files by line number. I can't find any, that's why I create a script by myself. Here is the results : #!/bin/bash # Cut a file into pieces # specifie delimiter line number with -l LINESLIST=&amp;#40;&amp;#41; FILENAME=&quot;&quot; while getopts f:l: option do case $option in f&amp;#41; FILENAME=$OPTARG ;; l&amp;#41; (...)

-
&lt;a href="http://blog.6tech.net/-Scripts-.html" rel="directory"&gt;Scripts&lt;/a&gt;

/ 
&lt;a href="http://blog.6tech.net/+-BASH,27-+.html" rel="tag"&gt;BASH&lt;/a&gt;

		</description>


 <content:encoded>&lt;div class='rss_texte'&gt;&lt;p&gt;I tried to look on a script/cmd which allow me to cut a file into several files by line number.&lt;/p&gt; &lt;p&gt;I can't find any, that's why I create a script by myself.&lt;/p&gt; &lt;p&gt;Here is the results :&lt;/p&gt; &lt;div class=&quot;coloration_code&quot;&gt;&lt;div class=&quot;spip_bash cadre&quot;&gt;&lt;div class=&quot;bash&quot;&gt;&lt;ol&gt;&lt;li style=&quot;font-weight: normal; vertical-align:top;&quot;&gt;&lt;div style=&quot;&quot;&gt;&lt;span style=&quot;color: #666666; font-style: italic;&quot;&gt;#!/bin/bash&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;
&lt;li style=&quot;font-weight: normal; vertical-align:top;&quot;&gt;&lt;div style=&quot;&quot;&gt;&lt;span style=&quot;color: #666666; font-style: italic;&quot;&gt;# Cut a file into pieces&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;
&lt;li style=&quot;font-weight: normal; vertical-align:top;&quot;&gt;&lt;div style=&quot;&quot;&gt;&lt;span style=&quot;color: #666666; font-style: italic;&quot;&gt;# specifie delimiter line number with -l&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;
&lt;li style=&quot;font-weight: normal; vertical-align:top;&quot;&gt;&lt;div style=&quot;&quot;&gt;&lt;span style=&quot;color: #007800;&quot;&gt;LINESLIST&lt;/span&gt;=&lt;span style=&quot;color: #7a0874; font-weight: bold;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #7a0874; font-weight: bold;&quot;&gt;&amp;#41;&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;
&lt;li style=&quot;font-weight: normal; vertical-align:top;&quot;&gt;&lt;div style=&quot;&quot;&gt;&lt;span style=&quot;color: #007800;&quot;&gt;FILENAME&lt;/span&gt;=&lt;span style=&quot;color: #ff0000;&quot;&gt;&quot;&quot;&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;
&lt;li style=&quot;font-weight: normal; vertical-align:top;&quot;&gt;&lt;div style=&quot;&quot;&gt;&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;while&lt;/span&gt; &lt;span style=&quot;color: #7a0874; font-weight: bold;&quot;&gt;getopts&lt;/span&gt; f:l: option&lt;/div&gt;&lt;/li&gt;
&lt;li style=&quot;font-weight: normal; vertical-align:top;&quot;&gt;&lt;div style=&quot;&quot;&gt;&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;do&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;
&lt;li style=&quot;font-weight: normal; vertical-align:top;&quot;&gt;&lt;div style=&quot;&quot;&gt; &lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;case&lt;/span&gt; &lt;span style=&quot;color: #007800;&quot;&gt;$option&lt;/span&gt; &lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;in&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;
&lt;li style=&quot;font-weight: normal; vertical-align:top;&quot;&gt;&lt;div style=&quot;&quot;&gt; f&lt;span style=&quot;color: #7a0874; font-weight: bold;&quot;&gt;&amp;#41;&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;
&lt;li style=&quot;font-weight: normal; vertical-align:top;&quot;&gt;&lt;div style=&quot;&quot;&gt; &lt;span style=&quot;color: #007800;&quot;&gt;FILENAME&lt;/span&gt;=&lt;span style=&quot;color: #007800;&quot;&gt;$OPTARG&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;
&lt;li style=&quot;font-weight: normal; vertical-align:top;&quot;&gt;&lt;div style=&quot;&quot;&gt; &lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;;;&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;
&lt;li style=&quot;font-weight: normal; vertical-align:top;&quot;&gt;&lt;div style=&quot;&quot;&gt; l&lt;span style=&quot;color: #7a0874; font-weight: bold;&quot;&gt;&amp;#41;&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;
&lt;li style=&quot;font-weight: normal; vertical-align:top;&quot;&gt;&lt;div style=&quot;&quot;&gt; &lt;span style=&quot;color: #007800;&quot;&gt;LINESLIST&lt;/span&gt;=&lt;span style=&quot;color: #7a0874; font-weight: bold;&quot;&gt;&amp;#40;&lt;/span&gt;$&lt;span style=&quot;color: #7a0874; font-weight: bold;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #7a0874; font-weight: bold;&quot;&gt;echo&lt;/span&gt; &lt;span style=&quot;color: #007800;&quot;&gt;$OPTARG&lt;/span&gt;&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;|&lt;/span&gt;&lt;span style=&quot;color: #c20cb9; font-weight: bold;&quot;&gt;tr&lt;/span&gt; &lt;span style=&quot;color: #ff0000;&quot;&gt;&quot;,&quot;&lt;/span&gt; &lt;span style=&quot;color: #ff0000;&quot;&gt;&quot; &quot;&lt;/span&gt;&lt;span style=&quot;color: #7a0874; font-weight: bold;&quot;&gt;&amp;#41;&lt;/span&gt;&lt;span style=&quot;color: #7a0874; font-weight: bold;&quot;&gt;&amp;#41;&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;
&lt;li style=&quot;font-weight: normal; vertical-align:top;&quot;&gt;&lt;div style=&quot;&quot;&gt; &lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;;;&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;
&lt;li style=&quot;font-weight: normal; vertical-align:top;&quot;&gt;&lt;div style=&quot;&quot;&gt; &lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;esac&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;
&lt;li style=&quot;font-weight: normal; vertical-align:top;&quot;&gt;&lt;div style=&quot;&quot;&gt;&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;done&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;
&lt;li style=&quot;font-weight: normal; vertical-align:top;&quot;&gt;&lt;div style=&quot;&quot;&gt;&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;if&lt;/span&gt; &lt;span style=&quot;color: #7a0874; font-weight: bold;&quot;&gt;&amp;#91;&lt;/span&gt; &lt;span style=&quot;color: #800000;&quot;&gt;${#LINESLIST}&lt;/span&gt; = &lt;span style=&quot;color: #000000;&quot;&gt;0&lt;/span&gt; &lt;span style=&quot;color: #7a0874; font-weight: bold;&quot;&gt;&amp;#93;&lt;/span&gt;; &lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;then&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;
&lt;li style=&quot;font-weight: normal; vertical-align:top;&quot;&gt;&lt;div style=&quot;&quot;&gt; &lt;span style=&quot;color: #7a0874; font-weight: bold;&quot;&gt;echo&lt;/span&gt; &lt;span style=&quot;color: #ff0000;&quot;&gt;&quot;lines list is empty&quot;&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;
&lt;li style=&quot;font-weight: normal; vertical-align:top;&quot;&gt;&lt;div style=&quot;&quot;&gt; &lt;span style=&quot;color: #7a0874; font-weight: bold;&quot;&gt;echo&lt;/span&gt; &lt;span style=&quot;color: #ff0000;&quot;&gt;&quot;use -l &lt;span style=&quot;color: #000099; font-weight: bold;&quot;&gt;\&quot;&lt;/span&gt;1000,2000,...&quot;&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;
&lt;li style=&quot;font-weight: normal; vertical-align:top;&quot;&gt;&lt;div style=&quot;&quot;&gt; &lt;span style=&quot;color: #7a0874; font-weight: bold;&quot;&gt;exit&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;
&lt;li style=&quot;font-weight: normal; vertical-align:top;&quot;&gt;&lt;div style=&quot;&quot;&gt;&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;fi&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;
&lt;li style=&quot;font-weight: normal; vertical-align:top;&quot;&gt;&lt;div style=&quot;&quot;&gt;&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;if&lt;/span&gt; &lt;span style=&quot;color: #7a0874; font-weight: bold;&quot;&gt;&amp;#91;&lt;/span&gt; &lt;span style=&quot;color: #660033;&quot;&gt;-z&lt;/span&gt; &lt;span style=&quot;color: #007800;&quot;&gt;$FILENAME&lt;/span&gt; &lt;span style=&quot;color: #7a0874; font-weight: bold;&quot;&gt;&amp;#93;&lt;/span&gt;; &lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;then&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;
&lt;li style=&quot;font-weight: normal; vertical-align:top;&quot;&gt;&lt;div style=&quot;&quot;&gt; &lt;span style=&quot;color: #7a0874; font-weight: bold;&quot;&gt;echo&lt;/span&gt; &lt;span style=&quot;color: #ff0000;&quot;&gt;&quot;filename is empty&quot;&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;
&lt;li style=&quot;font-weight: normal; vertical-align:top;&quot;&gt;&lt;div style=&quot;&quot;&gt; &lt;span style=&quot;color: #7a0874; font-weight: bold;&quot;&gt;echo&lt;/span&gt; &lt;span style=&quot;color: #ff0000;&quot;&gt;&quot;use -f &lt;span style=&quot;color: #000099; font-weight: bold;&quot;&gt;\&quot;&lt;/span&gt;filename&lt;span style=&quot;color: #000099; font-weight: bold;&quot;&gt;\&quot;&lt;/span&gt;&quot;&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;
&lt;li style=&quot;font-weight: normal; vertical-align:top;&quot;&gt;&lt;div style=&quot;&quot;&gt; &lt;span style=&quot;color: #7a0874; font-weight: bold;&quot;&gt;exit&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;
&lt;li style=&quot;font-weight: normal; vertical-align:top;&quot;&gt;&lt;div style=&quot;&quot;&gt;&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;fi&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;
&lt;li style=&quot;font-weight: normal; vertical-align:top;&quot;&gt;&lt;div style=&quot;&quot;&gt;&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;if&lt;/span&gt; &lt;span style=&quot;color: #7a0874; font-weight: bold;&quot;&gt;&amp;#91;&lt;/span&gt; &lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;!&lt;/span&gt; &lt;span style=&quot;color: #660033;&quot;&gt;-f&lt;/span&gt; &lt;span style=&quot;color: #007800;&quot;&gt;$FILENAME&lt;/span&gt; &lt;span style=&quot;color: #7a0874; font-weight: bold;&quot;&gt;&amp;#93;&lt;/span&gt;; &lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;then&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;
&lt;li style=&quot;font-weight: normal; vertical-align:top;&quot;&gt;&lt;div style=&quot;&quot;&gt; &lt;span style=&quot;color: #7a0874; font-weight: bold;&quot;&gt;echo&lt;/span&gt; &lt;span style=&quot;color: #ff0000;&quot;&gt;&quot;&lt;span style=&quot;color: #007800;&quot;&gt;$FILENAME&lt;/span&gt; doesnt exists&quot;&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;
&lt;li style=&quot;font-weight: normal; vertical-align:top;&quot;&gt;&lt;div style=&quot;&quot;&gt; &lt;span style=&quot;color: #7a0874; font-weight: bold;&quot;&gt;exit&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;
&lt;li style=&quot;font-weight: normal; vertical-align:top;&quot;&gt;&lt;div style=&quot;&quot;&gt;&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;fi&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;
&lt;li style=&quot;font-weight: normal; vertical-align:top;&quot;&gt;&lt;div style=&quot;&quot;&gt;&lt;span style=&quot;color: #666666; font-style: italic;&quot;&gt;# start cut &lt;/span&gt;&lt;/div&gt;&lt;/li&gt;
&lt;li style=&quot;font-weight: normal; vertical-align:top;&quot;&gt;&lt;div style=&quot;&quot;&gt;&lt;span style=&quot;color: #007800;&quot;&gt;CURRENT&lt;/span&gt;=&lt;span style=&quot;color: #000000;&quot;&gt;0&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;
&lt;li style=&quot;font-weight: normal; vertical-align:top;&quot;&gt;&lt;div style=&quot;&quot;&gt;&lt;span style=&quot;color: #007800;&quot;&gt;CURRENTFILE&lt;/span&gt;=&lt;span style=&quot;color: #ff0000;&quot;&gt;&quot;&quot;&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;
&lt;li style=&quot;font-weight: normal; vertical-align:top;&quot;&gt;&lt;div style=&quot;&quot;&gt;&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;for&lt;/span&gt; line &lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;in&lt;/span&gt; &lt;span style=&quot;color: #800000;&quot;&gt;${LINESLIST[@]}&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;
&lt;li style=&quot;font-weight: normal; vertical-align:top;&quot;&gt;&lt;div style=&quot;&quot;&gt;&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;do&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;
&lt;li style=&quot;font-weight: normal; vertical-align:top;&quot;&gt;&lt;div style=&quot;&quot;&gt; &lt;span style=&quot;color: #007800;&quot;&gt;START&lt;/span&gt;=&lt;span style=&quot;color: #007800;&quot;&gt;$CURRENT&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;
&lt;li style=&quot;font-weight: normal; vertical-align:top;&quot;&gt;&lt;div style=&quot;&quot;&gt; &lt;span style=&quot;color: #007800;&quot;&gt;END&lt;/span&gt;=&lt;span style=&quot;color: #007800;&quot;&gt;$line&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;
&lt;li style=&quot;font-weight: normal; vertical-align:top;&quot;&gt;&lt;div style=&quot;&quot;&gt; &lt;span style=&quot;color: #007800;&quot;&gt;LENGTH&lt;/span&gt;=$&lt;span style=&quot;color: #7a0874; font-weight: bold;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #7a0874; font-weight: bold;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #007800;&quot;&gt;$END&lt;/span&gt;-&lt;span style=&quot;color: #007800;&quot;&gt;$START&lt;/span&gt;&lt;span style=&quot;color: #7a0874; font-weight: bold;&quot;&gt;&amp;#41;&lt;/span&gt;&lt;span style=&quot;color: #7a0874; font-weight: bold;&quot;&gt;&amp;#41;&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;
&lt;li style=&quot;font-weight: normal; vertical-align:top;&quot;&gt;&lt;div style=&quot;&quot;&gt; &lt;span style=&quot;color: #7a0874; font-weight: bold;&quot;&gt;echo&lt;/span&gt; &lt;span style=&quot;color: #ff0000;&quot;&gt;&quot;cut &lt;span style=&quot;color: #007800;&quot;&gt;$START&lt;/span&gt; to &lt;span style=&quot;color: #007800;&quot;&gt;$END&lt;/span&gt; (length &lt;span style=&quot;color: #007800;&quot;&gt;$LENGTH&lt;/span&gt;)&quot;&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;
&lt;li style=&quot;font-weight: normal; vertical-align:top;&quot;&gt;&lt;div style=&quot;&quot;&gt; &lt;span style=&quot;color: #007800;&quot;&gt;CURRENTFILE&lt;/span&gt;=&lt;span style=&quot;color: #ff0000;&quot;&gt;&quot;&lt;span style=&quot;color: #007800;&quot;&gt;$FILENAME&lt;/span&gt;.&lt;span style=&quot;color: #007800;&quot;&gt;$START&lt;/span&gt;-&lt;span style=&quot;color: #007800;&quot;&gt;$END&lt;/span&gt;&quot;&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;
&lt;li style=&quot;font-weight: normal; vertical-align:top;&quot;&gt;&lt;div style=&quot;&quot;&gt; &lt;span style=&quot;color: #7a0874; font-weight: bold;&quot;&gt;&amp;#91;&lt;/span&gt; &lt;span style=&quot;color: #ff0000;&quot;&gt;&quot;&lt;span style=&quot;color: #007800;&quot;&gt;$START&lt;/span&gt;&quot;&lt;/span&gt; = &lt;span style=&quot;color: #ff0000;&quot;&gt;&quot;0&quot;&lt;/span&gt; &lt;span style=&quot;color: #7a0874; font-weight: bold;&quot;&gt;&amp;#93;&lt;/span&gt; &lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;&amp;&amp;&lt;/span&gt; &lt;span style=&quot;color: #007800;&quot;&gt;START&lt;/span&gt;=&lt;span style=&quot;color: #007800;&quot;&gt;$END&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;
&lt;li style=&quot;font-weight: normal; vertical-align:top;&quot;&gt;&lt;div style=&quot;&quot;&gt; &lt;span style=&quot;color: #c20cb9; font-weight: bold;&quot;&gt;head&lt;/span&gt; &lt;span style=&quot;color: #660033;&quot;&gt;-n&lt;/span&gt; &lt;span style=&quot;color: #007800;&quot;&gt;$END&lt;/span&gt; &lt;span style=&quot;color: #007800;&quot;&gt;$FILENAME&lt;/span&gt; &lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;|&lt;/span&gt; &lt;span style=&quot;color: #c20cb9; font-weight: bold;&quot;&gt;tail&lt;/span&gt; &lt;span style=&quot;color: #660033;&quot;&gt;-n&lt;/span&gt; &lt;span style=&quot;color: #007800;&quot;&gt;$LENGTH&lt;/span&gt; &lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;&gt;&lt;/span&gt; &lt;span style=&quot;color: #007800;&quot;&gt;$CURRENTFILE&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;
&lt;li style=&quot;font-weight: normal; vertical-align:top;&quot;&gt;&lt;div style=&quot;&quot;&gt; &lt;span style=&quot;color: #007800;&quot;&gt;CURRENT&lt;/span&gt;=&lt;span style=&quot;color: #007800;&quot;&gt;$END&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;
&lt;li style=&quot;font-weight: normal; vertical-align:top;&quot;&gt;&lt;div style=&quot;&quot;&gt;&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;done&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;
&lt;/ol&gt;&lt;/div&gt;&lt;/div&gt;&lt;div class='cadre_download' style='text-align: right;'&gt; &lt;a href='http://blog.6tech.net/local/cache-code/2ad8e1b40a36f56379e349f3206da64b.txt' style='font-family: verdana, arial, sans; font-weight: bold; font-style: normal;'&gt;T&#233;l&#233;charger&lt;/a&gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;
		
		</content:encoded>


		

	</item>
<item xml:lang="fr">
		<title>Pool de connexion</title>
		<link>http://blog.6tech.net/Pool-de-connexion,43.html</link>
		<guid isPermaLink="true">http://blog.6tech.net/Pool-de-connexion,43.html</guid>
		<dc:date>2008-04-08T22:14:57Z</dc:date>
		<dc:format>text/html</dc:format>
		<dc:language>fr</dc:language>
		


		<dc:subject>J2EE</dc:subject>
		<dc:subject>Struts</dc:subject>

		<description>La gestion des base de donn&#233;es sous Struts est un vrai probl&#232;me. Les tags du framework ( tel &lt;sql:setDataSource&gt; ) commence &#224; perturber l'id&#233;e originelle de Struts. Struts n'est qu'un framework de pr&#233;sentation, et le fait de lui permettre de g&#233;rer les bases de donn&#233;es revient &#224; m&#233;langer les diff&#233;rentes couches d'une application MVC2 . Il est donc conseill&#233; de ne pas utiliser cette librairie de tag ( qui devrait dispara&#238;tre dans les versions futures ) Une meilleur approche serait de configurer la (...)

-
&lt;a href="http://blog.6tech.net/-tutoriaux,7-.html" rel="directory"&gt;Tutoriaux&lt;/a&gt;

/ 
&lt;a href="http://blog.6tech.net/+-j2ee,4-+.html" rel="tag"&gt;J2EE&lt;/a&gt;, 
&lt;a href="http://blog.6tech.net/+-struts,26-+.html" rel="tag"&gt;Struts&lt;/a&gt;

		</description>


 <content:encoded>&lt;div class='rss_texte'&gt;&lt;div class=&quot;cs_sommaire cs_sommaire_avec_fond&quot; id=&quot;outil_sommaire&quot;&gt; &lt;div class=&quot;cs_sommaire_inner&quot;&gt; &lt;div class=&quot;cs_sommaire_titre_avec_fond&quot;&gt; Sommaire &lt;/div&gt; &lt;ul&gt; &lt;li&gt;&lt;a title=&quot;Configuration du pool&quot; href=&quot;http://blog.6tech.net/spip.php?page=backend#outil_sommaire_0&quot;&gt;Configuration du pool&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a title=&quot;Lier le pool &#224; l&amp;#39;application&quot; href=&quot;http://blog.6tech.net/spip.php?page=backend#outil_sommaire_1&quot;&gt;Lier le pool &#224; l'application&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a title=&quot;L&amp;#39;utilisation dans vos servlets&quot; href=&quot;http://blog.6tech.net/spip.php?page=backend#outil_sommaire_2&quot;&gt;L'utilisation dans vos (...)&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a title=&quot;Erreurs fr&#233;quentes&quot; href=&quot;http://blog.6tech.net/spip.php?page=backend#outil_sommaire_3&quot;&gt;Erreurs fr&#233;quentes&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a title=&quot;Derni&#232;res pr&#233;cisions&quot; href=&quot;http://blog.6tech.net/spip.php?page=backend#outil_sommaire_4&quot;&gt;Derni&#232;res pr&#233;cisions&lt;/a&gt;&lt;/li&gt; &lt;/ul&gt; &lt;/div&gt; &lt;/div&gt;&lt;p&gt;La gestion des base de donn&#233;es sous Struts est un vrai probl&#232;me. Les tags du framework ( tel &lt;sql:setDataSource&gt; ) commence &#224; perturber l'id&#233;e originelle de Struts. Struts n'est qu'un framework de pr&#233;sentation, et le fait de lui permettre de g&#233;rer les bases de donn&#233;es revient &#224; m&#233;langer les diff&#233;rentes couches d'une application MVC2 .
Il est donc conseill&#233; de ne pas utiliser cette librairie de tag ( qui devrait dispara&#238;tre dans les versions futures )&lt;/p&gt; &lt;p&gt;Une meilleur approche serait de configurer la gestion de ses bases de donn&#233;es par tomcat lui m&#234;me gr&#226;ce encore une fois au fameux fichier de context : &lt;strong&gt;/META-INF/context.xml&lt;/strong&gt; . Quelques lignes permettront de peaufiner toute une gestion tel que le nombre de connexion maximale, le nombre minimal &#224; pr&#233;voir, le timeout, etc. Ce que l'on appel un pool de connexion !&lt;/p&gt; &lt;h3 class=&quot;spip&quot; id=&quot;outil_sommaire_0&quot;&gt;&lt;a title=&quot;Sommaire&quot; href=&quot;http://blog.6tech.net/spip.php?page=backend#outil_sommaire&quot; class=&quot;sommaire_ancre&quot;&gt; &lt;/a&gt;Configuration du pool&lt;/h3&gt;
&lt;p&gt;La configuration commence donc par ces quelques lignes dans un fichier context.xml :&lt;/p&gt;
&lt;div style='text-align: left;' class='spip_code' dir='ltr'&gt;&lt;code&gt;&lt;Context reloadable=&quot;true&quot;&gt;&lt;br /&gt; &lt;Resource name=&quot;jdbc/myProject&quot; auth=&quot;Container&quot;&lt;br /&gt; type=&quot;javax.sql.DataSource&quot;&lt;br /&gt; username=&quot;database_user&quot; password=&quot;database_passwd&quot;&lt;br /&gt; driverClassName=&quot;com.mysql.jdbc.Driver&quot;&lt;br /&gt; url=&quot;jdbc:mysql://localhost:3306/database_base&quot; maxActive=&quot;8&quot; maxIdle=&quot;8&quot;&lt;br /&gt; removeAbandoned=&quot;true&quot; removeAbandonedTimeout=&quot;30&quot; logAbandoned=&quot;true&quot; /&gt;&lt;br /&gt; &lt;/Context&gt;&lt;/code&gt;&lt;/div&gt;
&lt;p&gt;Pour la signification des attributs je vous sugg&#232;re d'aller voir : &lt;a href=&quot;http://commons.apache.org/dbcp/configuration.html&quot; class='spip_out' rel='external'&gt;common apache&lt;/a&gt;&lt;/p&gt; &lt;h3 class=&quot;spip&quot; id=&quot;outil_sommaire_1&quot;&gt;&lt;a title=&quot;Sommaire&quot; href=&quot;http://blog.6tech.net/spip.php?page=backend#outil_sommaire&quot; class=&quot;sommaire_ancre&quot;&gt; &lt;/a&gt;Lier le pool &#224; l'application&lt;/h3&gt;
&lt;p&gt;Une fois ce pool cr&#233;&#233;, il peut &#234;tre int&#233;ressant de le lier &#224; l'application dans son fichier web.xml par la balise resource-ref :&lt;/p&gt; &lt;div style='text-align: left;' class='spip_code' dir='ltr'&gt;&lt;code&gt; &lt;resource-ref&gt;&lt;br /&gt; &lt;description&gt;&lt;br /&gt; Pool de connexion &#224; la base de donn&#233;es&lt;br /&gt; &lt;/description&gt;&lt;br /&gt; &lt;res-ref-name&gt;jdbc/myProject&lt;/res-ref-name&gt;&lt;br /&gt; &lt;res-type&gt;javax.sql.DataSource&lt;/res-type&gt;&lt;br /&gt; &lt;res-auth&gt;Container&lt;/res-auth&gt;&lt;br /&gt; &lt;/resource-ref&gt;&lt;/code&gt;&lt;/div&gt;
&lt;h3 class=&quot;spip&quot; id=&quot;outil_sommaire_2&quot;&gt;&lt;a title=&quot;Sommaire&quot; href=&quot;http://blog.6tech.net/spip.php?page=backend#outil_sommaire&quot; class=&quot;sommaire_ancre&quot;&gt; &lt;/a&gt;L'utilisation dans vos servlets&lt;/h3&gt;
&lt;p&gt;Ensuite pour l'utiliser, il vous suffira de r&#233;cup&#233;rer une connexion du context par ces quelques lignes :&lt;/p&gt;
&lt;div style='text-align: left;' class='spip_code' dir='ltr'&gt;&lt;code&gt; try {&lt;br /&gt; Context initCtx = new InitialContext(); // r&#233;cup&#233;ration du context&lt;br /&gt; DataSource ds = (DataSource) initCtx.lookup(&quot;java:comp/env/jdbc/myProject&quot;); // r&#233;cup&#233;ration de la source&lt;br /&gt; Connection con = ds.getConnection(); // r&#233;cup&#233;ration de la connexion&lt;br /&gt; .....&lt;br /&gt; } catch (Exception e) {&lt;br /&gt; Logger.getLogger(this.CLASS).error(&quot;DATABASE : &quot;+e.getMessage());&lt;br /&gt; }&lt;/code&gt;&lt;/div&gt;
&lt;p&gt;Il pourra &#234;tre subtil de cr&#233;er une classe s'occupant de r&#233;cup&#233;rer cette connexion et d'effectuer une requ&#234;te dessus.&lt;/p&gt; &lt;h3 class=&quot;spip&quot; id=&quot;outil_sommaire_3&quot;&gt;&lt;a title=&quot;Sommaire&quot; href=&quot;http://blog.6tech.net/spip.php?page=backend#outil_sommaire&quot; class=&quot;sommaire_ancre&quot;&gt; &lt;/a&gt;Erreurs fr&#233;quentes&lt;/h3&gt;
&lt;p&gt;Attention toute fois &#224; bien comprendre ce que vous faites. La cr&#233;ation d'un pool de connexion et sa limitation implique de fermer correctement toute demande de connexion une fois la requ&#234;te achev&#233;e. Un appel &#224; con.close() terminera la connexion courrante, mais prenez garde &#224; bien fermer vos ResultSet et PreparedStatement dans le bon ordre et avant la fermeture de la connexion principale.&lt;/p&gt; &lt;p&gt;Si votre script se bloque ou se met en pause ; cela est g&#233;n&#233;ralement du &#224; l'oubli de fermeture de connexion. Le pool de connexion voyant son capital de connexions s'amenuiser, ne distribuera plus de nouvelles connexions tant que les pr&#233;c&#233;dentes n'auront pas &#233;t&#233; lib&#233;r&#233;es ..&lt;/p&gt; &lt;h3 class=&quot;spip&quot; id=&quot;outil_sommaire_4&quot;&gt;&lt;a title=&quot;Sommaire&quot; href=&quot;http://blog.6tech.net/spip.php?page=backend#outil_sommaire&quot; class=&quot;sommaire_ancre&quot;&gt; &lt;/a&gt;Derni&#232;res pr&#233;cisions&lt;/h3&gt;
&lt;ul class=&quot;spip&quot;&gt;&lt;li&gt; Si vraiment, vraiment, vraiment vous pr&#233;f&#233;rez quand m&#234;me, contre toute opposition sens&#233;e et argument&#233;e, utiliser la taglib 'sql' de struts, vous pouvez en haut de vos pages renseigner la source pr&#233;c&#233;demment configur&#233;e dans le web.xml et dans le context.xml par &lt;code class='spip_code' dir='ltr'&gt;&lt;sql:setDataSource dataSource=&quot;jdbc/myProject&quot; /&gt;&lt;/code&gt;&lt;/li&gt;&lt;/ul&gt;
&lt;ul class=&quot;spip&quot;&gt;&lt;li&gt; Vous pouvez &#233;galement vouloir configurer un pool de connexion au niveau du serveur tomcat directement, et partager ce pool avec plusieurs applications en cr&#233;ant une section ressource dans le server.xml (plus facilement faisable par l'administration de tomcat ) ; ensuite il conviendra de sp&#233;cifier dans chaque contexte le pool &#224; utiliser par :
&lt;div style='text-align: left;' class='spip_code' dir='ltr'&gt;&lt;code&gt;&lt;ResourceLink&lt;br /&gt; name=&quot;jdbc/myProject&quot;&lt;br /&gt; global=&quot;jdbc/myProject&quot;&lt;br /&gt; type=&quot;javax.sql.DataSource&quot;/&gt;&lt;/code&gt;&lt;/div&gt;&lt;/li&gt;&lt;/ul&gt;
&lt;p&gt;Cette solution &#233;carte l'&#233;tape de configuration du web.xml&lt;/p&gt;&lt;/div&gt;
		
		</content:encoded>


		

	</item>
<item xml:lang="fr">
		<title>Paradigme des fonctions</title>
		<link>http://blog.6tech.net/paradigme-des-fonctions,42.html</link>
		<guid isPermaLink="true">http://blog.6tech.net/paradigme-des-fonctions,42.html</guid>
		<dc:date>2008-04-08T21:28:16Z</dc:date>
		<dc:format>text/html</dc:format>
		<dc:language>fr</dc:language>
		


		<dc:subject>PHP</dc:subject>
		<dc:subject>Fonctions</dc:subject>

		<description>Ceci est un post &#224; vues p&#233;dagogiques sur la cr&#233;ation de fonctions php. Tout le monde utilise les fonctions de php telles que explode(), strpos(), mysql_db_query(), etc . Mais qui n'a jamais voulu en cr&#233;er lui m&#234;me ? la cr&#233;ation/utilisation de fonctions suit 2 &#233;tapes : Tout d'abord, commen&#231;ons par le commencement : la d&#233;claration Elle ( la d&#233;claration) commence par le mot-cl&#233; : function et ce, selon la syntaxe suivante : function NomDeLaFonction(arg1,arg2,arg3 .... ) corps de la fonction ; La (...)

-
&lt;a href="http://blog.6tech.net/-tutoriaux,7-.html" rel="directory"&gt;Tutoriaux&lt;/a&gt;

/ 
&lt;a href="http://blog.6tech.net/+-php,1-+.html" rel="tag"&gt;PHP&lt;/a&gt;, 
&lt;a href="http://blog.6tech.net/+-fonctions,23-+.html" rel="tag"&gt;Fonctions&lt;/a&gt;

		</description>


 <content:encoded>&lt;div class='rss_texte'&gt;&lt;div class=&quot;cs_sommaire cs_sommaire_avec_fond&quot; id=&quot;outil_sommaire&quot;&gt; &lt;div class=&quot;cs_sommaire_inner&quot;&gt; &lt;div class=&quot;cs_sommaire_titre_avec_fond&quot;&gt; Sommaire &lt;/div&gt; &lt;ul&gt; &lt;li&gt;&lt;a title=&quot;la d&#233;claration&quot; href=&quot;http://blog.6tech.net/spip.php?page=backend#outil_sommaire_0&quot;&gt;la d&#233;claration&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a title=&quot;L&amp;#39;appel de la fonction&quot; href=&quot;http://blog.6tech.net/spip.php?page=backend#outil_sommaire_1&quot;&gt;L'appel de la fonction&lt;/a&gt;&lt;/li&gt; &lt;/ul&gt; &lt;/div&gt; &lt;/div&gt;&lt;p&gt;Ceci est un post &#224; vues p&#233;dagogiques sur la cr&#233;ation de fonctions php.&lt;/p&gt; &lt;p&gt;Tout le monde utilise les fonctions de php telles que &lt;i&gt;explode()&lt;/i&gt;, &lt;i&gt;strpos()&lt;/i&gt;, &lt;i&gt;mysql_db_query()&lt;/i&gt;, etc .
Mais qui n'a jamais voulu en cr&#233;er lui m&#234;me ? la cr&#233;ation/utilisation de fonctions suit 2 &#233;tapes :&lt;/p&gt; &lt;p&gt;Tout d'abord, commen&#231;ons par le commencement :&lt;/p&gt; &lt;h3 class=&quot;spip&quot; id=&quot;outil_sommaire_0&quot;&gt;&lt;a title=&quot;Sommaire&quot; href=&quot;http://blog.6tech.net/spip.php?page=backend#outil_sommaire&quot; class=&quot;sommaire_ancre&quot;&gt; &lt;/a&gt;la d&#233;claration &lt;/h3&gt;
&lt;p&gt;Elle ( la d&#233;claration [&lt;a href='#nb1' class='spip_note' rel='footnote' title='doit se faire obligatoirement avant l'appel de la fonction' id='nh1'&gt;1&lt;/a&gt;]) commence par le mot-cl&#233; : &lt;i&gt;function&lt;/i&gt; et ce, selon la syntaxe suivante :&lt;/p&gt;
&lt;div style='text-align: left;' class='spip_code' dir='ltr'&gt;&lt;code&gt; function NomDeLaFonction(arg1,arg2,arg3 .... ){&lt;br /&gt; corps de la fonction;&lt;br /&gt; }&lt;/code&gt;&lt;/div&gt;
&lt;p&gt;La fonction peut tr&#232;s bien ne prendre aucun argument.
Dans le corps de la fonction vous mettez les instructions destin&#233;es &#224; &#234;tre ex&#233;cut&#233;es.&lt;/p&gt; &lt;p&gt;&lt;strong&gt;Exemple de fonction&lt;/strong&gt;&lt;/p&gt;
&lt;div style='text-align: left;' class='spip_code' dir='ltr'&gt;&lt;code&gt;function affiche_text_gras($texte){&lt;br /&gt; echo &quot;&lt;b&gt;&quot;.$texte.&quot;&lt;/b&gt;&quot;; &lt;br /&gt; }&lt;/code&gt;&lt;/div&gt;
&lt;p&gt; // affiche un texte en gras&lt;/p&gt; &lt;p&gt;Une fonction peut &#233;galement renvoyer une valeur &#224; son ex&#233;cution gr&#226;ce au mot-cl&#233; : &lt;i&gt;return&lt;/i&gt;&lt;/p&gt; &lt;p&gt;&lt;strong&gt;Exemple de fonction&lt;/strong&gt;&lt;/p&gt;
&lt;div style='text-align: left;' class='spip_code' dir='ltr'&gt;&lt;code&gt;function carre($nb){&lt;br /&gt; return $nb*$nb; //retourne le carr&#233; d'un nombre&lt;br /&gt; }&lt;/code&gt;&lt;/div&gt;
&lt;h3 class=&quot;spip&quot; id=&quot;outil_sommaire_1&quot;&gt;&lt;a title=&quot;Sommaire&quot; href=&quot;http://blog.6tech.net/spip.php?page=backend#outil_sommaire&quot; class=&quot;sommaire_ancre&quot;&gt; &lt;/a&gt;L'appel de la fonction&lt;/h3&gt;
&lt;p&gt;l'appel se fait de fa&#231;on explicite :&lt;/p&gt; &lt;ul class=&quot;spip&quot;&gt;&lt;li&gt; Si la fonction retourne une variable, il faut affecter &#224; une variable le r&#233;sultat de la fonction : $variable = NomDeLaFonction($arg1,$arg2, ....) ; // autant de $arg que d'argument&lt;/li&gt;&lt;li&gt; Si la fonction n'en retourne pas :
NomDeLaFonction($arg1,$arg2...) ; // autant de $arg que d'argument&lt;/li&gt;&lt;/ul&gt;&lt;/div&gt;
		&lt;hr /&gt;
		&lt;div class='rss_notes'&gt;&lt;p&gt;&lt;span class=&quot;csfoo htmla&quot;&gt;&lt;/span&gt;[&lt;a href='#nh1' id='nb1' class='spip_note' title='Notes 1' rev='footnote'&gt;1&lt;/a&gt;] &lt;span class=&quot;csfoo htmlb&quot;&gt;&lt;/span&gt;doit se faire obligatoirement avant l'appel de la fonction&lt;/p&gt;&lt;/div&gt;
		
		</content:encoded>


		

	</item>
<item xml:lang="fr">
		<title>Mail HTML en image</title>
		<link>http://blog.6tech.net/mail-html-en-image,41.html</link>
		<guid isPermaLink="true">http://blog.6tech.net/mail-html-en-image,41.html</guid>
		<dc:date>2008-04-08T21:22:35Z</dc:date>
		<dc:format>text/html</dc:format>
		<dc:language>fr</dc:language>
		


		<dc:subject>PHP</dc:subject>
		<dc:subject>Mail</dc:subject>

		<description>Il arrive parfois de vouloir envoyer un mail en HTML et d'y incorporer des images. G&#233;n&#233;ralement, il suffit de placer l'adresse absolue de l'image dans le tag correspondant. Cependant, il peut &#234;tre n&#233;cessaire de lier l'image dans le mail, pour par exemple pouvoir relire le mail hors connexion. Les diff&#233;rentes composantes d'un mail Dans un mail il y a 3 grosses parties : Les ent&#234;tes qui indiquent ce que contient le mail, qui est le destinataire, qui est l'envoyeur, &#224; qui faut il r&#233;pondre, .... (...)

-
&lt;a href="http://blog.6tech.net/-tutoriaux,7-.html" rel="directory"&gt;Tutoriaux&lt;/a&gt;

/ 
&lt;a href="http://blog.6tech.net/+-php,1-+.html" rel="tag"&gt;PHP&lt;/a&gt;, 
&lt;a href="http://blog.6tech.net/+-mail,24-+.html" rel="tag"&gt;Mail&lt;/a&gt;

		</description>


 <content:encoded>&lt;div class='rss_texte'&gt;&lt;div class=&quot;cs_sommaire cs_sommaire_avec_fond&quot; id=&quot;outil_sommaire&quot;&gt; &lt;div class=&quot;cs_sommaire_inner&quot;&gt; &lt;div class=&quot;cs_sommaire_titre_avec_fond&quot;&gt; Sommaire &lt;/div&gt; &lt;ul&gt; &lt;li&gt;&lt;a title=&quot;Le d&#233;limiteur&quot; href=&quot;http://blog.6tech.net/spip.php?page=backend#outil_sommaire_0&quot;&gt;Le d&#233;limiteur&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a title=&quot;Les ent&#234;tes&quot; href=&quot;http://blog.6tech.net/spip.php?page=backend#outil_sommaire_1&quot;&gt;Les ent&#234;tes&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a title=&quot;R&#233;f&#233;rencer les images dans le mail&quot; href=&quot;http://blog.6tech.net/spip.php?page=backend#outil_sommaire_2&quot;&gt;R&#233;f&#233;rencer les images dans (...)&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a title=&quot;Renseigner le corps du message&quot; href=&quot;http://blog.6tech.net/spip.php?page=backend#outil_sommaire_3&quot;&gt;Renseigner le corps du (...)&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a title=&quot;Attacher les images&quot; href=&quot;http://blog.6tech.net/spip.php?page=backend#outil_sommaire_4&quot;&gt;Attacher les images&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a title=&quot;Exemple&quot; href=&quot;http://blog.6tech.net/spip.php?page=backend#outil_sommaire_5&quot;&gt;Exemple&lt;/a&gt;&lt;/li&gt; &lt;/ul&gt; &lt;/div&gt; &lt;/div&gt;&lt;p&gt;Il arrive parfois de vouloir envoyer un mail en HTML et d'y incorporer des images. G&#233;n&#233;ralement, il suffit de placer l'adresse absolue de l'image dans le tag &lt;img&gt; correspondant. Cependant, il peut &#234;tre n&#233;cessaire de lier l'image dans le mail, pour par exemple pouvoir relire le mail hors connexion.&lt;/p&gt; &lt;p&gt;&lt;strong&gt; Les diff&#233;rentes composantes d'un mail &lt;/strong&gt;&lt;/p&gt; &lt;p&gt;Dans un mail il y a 3 grosses parties :&lt;/p&gt; &lt;ul class=&quot;spip&quot;&gt;&lt;li&gt; Les ent&#234;tes qui indiquent ce que contient le mail, qui est le destinataire, qui est l'envoyeur, &#224; qui faut il r&#233;pondre, ....&lt;/li&gt;&lt;li&gt; Le corps du message ( qu'il soit en HTML ou en texte simple )&lt;/li&gt;&lt;li&gt; Les fichiers joins ( images, documents, ...) &lt;/li&gt;&lt;/ul&gt;
&lt;p&gt;Ces trois parties sont s&#233;par&#233;es par un d&#233;limiteur qu'il convient de renseigner dans les ent&#234;tes du mail.&lt;/p&gt; &lt;h3 class=&quot;spip&quot; id=&quot;outil_sommaire_0&quot;&gt;&lt;a title=&quot;Sommaire&quot; href=&quot;http://blog.6tech.net/spip.php?page=backend#outil_sommaire&quot; class=&quot;sommaire_ancre&quot;&gt; &lt;/a&gt; Le d&#233;limiteur &lt;/h3&gt;
&lt;p&gt;Il convient d'utiliser une s&#233;quence difficile &#224; retrouver dans le reste du mail ( de fa&#231;on &#224; ne pas confondre une occurrence d'un texte avec le d&#233;limiteur ). On va le d&#233;finir de la fa&#231;on suivante et r&#233;cup&#233;rer un d&#233;limiteur de 32 caract&#232;res.&lt;/p&gt; &lt;p&gt;&lt;code&gt;&lt;span style=&quot;color: #000000&quot;&gt;
&lt;span style=&quot;color: #0000BB&quot;&gt;&lt;?php&lt;br /&gt; $delimiteur &lt;/span&gt;&lt;span style=&quot;color: #007700&quot;&gt;= &lt;/span&gt;&lt;span style=&quot;color: #DD0000&quot;&gt;'--'&lt;/span&gt;&lt;span style=&quot;color: #007700&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color: #DD0000&quot;&gt;'---='&lt;/span&gt;&lt;span style=&quot;color: #007700&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color: #0000BB&quot;&gt;md5&lt;/span&gt;&lt;span style=&quot;color: #007700&quot;&gt;( &lt;/span&gt;&lt;span style=&quot;color: #0000BB&quot;&gt;uniqid&lt;/span&gt;&lt;span style=&quot;color: #007700&quot;&gt;( &lt;/span&gt;&lt;span style=&quot;color: #0000BB&quot;&gt;rand&lt;/span&gt;&lt;span style=&quot;color: #007700&quot;&gt;() ) );&lt;br /&gt;&lt;/span&gt;&lt;span style=&quot;color: #0000BB&quot;&gt;?&gt;&lt;/span&gt;
&lt;/span&gt;
&lt;/code&gt;&lt;/p&gt; &lt;p&gt;&lt;i&gt; J'ai du couper les 4 tirets du d&#233;limiteur pour contrer les raccourci typographiques de spip :) &lt;/i&gt;&lt;/p&gt; &lt;h3 class=&quot;spip&quot; id=&quot;outil_sommaire_1&quot;&gt;&lt;a title=&quot;Sommaire&quot; href=&quot;http://blog.6tech.net/spip.php?page=backend#outil_sommaire&quot; class=&quot;sommaire_ancre&quot;&gt; &lt;/a&gt; Les ent&#234;tes &lt;/h3&gt;
&lt;p&gt;Les ent&#234;tes sont importantes, une erreur bien plac&#233;e pourrait vous donner l'envie de vous arracher les cheveux pendant 2 semaines sans jamais trouver la source de l'erreur.&lt;/p&gt; &lt;p&gt;On va d&#233;finir le type &lt;a href=&quot;http://fr.wikipedia.org/wiki/Multipurpose_Internet_Mail_Extensions&quot; class='spip_out' rel='external'&gt;MIME&lt;/a&gt; du message, , le sous type ou la nature du contenu du mail ( pr&#233;sentement &#171; related &#187; [&lt;a href='#nb2-1' class='spip_note' rel='footnote' title='permet de sp&#233;cifier que les diff&#233;rentes parties du message devrait &#234;tre (...)' id='nh2-1'&gt;1&lt;/a&gt;] ), l'adresse &#224; laquelle r&#233;pondre et l'envoyeur. On d&#233;finit &#233;galement quel sera la s&#233;quence du d&#233;limiteur servant &#224; d&#233;partager les diff&#233;rentes informations du mail.&lt;/p&gt; &lt;p&gt;&lt;code&gt;&lt;span style=&quot;color: #000000&quot;&gt;
&lt;span style=&quot;color: #0000BB&quot;&gt;&lt;?php&lt;br /&gt; $headers &lt;/span&gt;&lt;span style=&quot;color: #007700&quot;&gt;= &lt;/span&gt;&lt;span style=&quot;color: #DD0000&quot;&gt;&quot;MIME-Version: 1.0\r\n&quot;&lt;/span&gt;&lt;span style=&quot;color: #007700&quot;&gt;;&lt;br /&gt; &lt;/span&gt;&lt;span style=&quot;color: #0000BB&quot;&gt;$headers &lt;/span&gt;&lt;span style=&quot;color: #007700&quot;&gt;.= &lt;/span&gt;&lt;span style=&quot;color: #DD0000&quot;&gt;&quot;Content-Type: multipart/related; boundary=\&quot;$delimiteur\&quot;\r\n&quot;&lt;/span&gt;&lt;span style=&quot;color: #007700&quot;&gt;;&lt;br /&gt; &lt;/span&gt;&lt;span style=&quot;color: #0000BB&quot;&gt;$headers &lt;/span&gt;&lt;span style=&quot;color: #007700&quot;&gt;.= &lt;/span&gt;&lt;span style=&quot;color: #DD0000&quot;&gt;&quot;Reply-to: $from\r\n&quot;&lt;/span&gt;&lt;span style=&quot;color: #007700&quot;&gt;;&lt;br /&gt; &lt;/span&gt;&lt;span style=&quot;color: #0000BB&quot;&gt;$headers &lt;/span&gt;&lt;span style=&quot;color: #007700&quot;&gt;.= &lt;/span&gt;&lt;span style=&quot;color: #DD0000&quot;&gt;&quot;From: $from\r\n&quot;&lt;/span&gt;&lt;span style=&quot;color: #007700&quot;&gt;;&lt;br /&gt; &lt;/span&gt;&lt;span style=&quot;color: #0000BB&quot;&gt;$headers &lt;/span&gt;&lt;span style=&quot;color: #007700&quot;&gt;.= &lt;/span&gt;&lt;span style=&quot;color: #DD0000&quot;&gt;&quot;\r\n&quot;&lt;/span&gt;&lt;span style=&quot;color: #007700&quot;&gt;;&lt;br /&gt;&lt;/span&gt;&lt;span style=&quot;color: #0000BB&quot;&gt;?&gt;&lt;/span&gt;
&lt;/span&gt;
&lt;/code&gt;&lt;/p&gt; &lt;p&gt;( ceci est une liste non exhaustive d'ent&#234;tes )&lt;/p&gt; &lt;h3 class=&quot;spip&quot; id=&quot;outil_sommaire_2&quot;&gt;&lt;a title=&quot;Sommaire&quot; href=&quot;http://blog.6tech.net/spip.php?page=backend#outil_sommaire&quot; class=&quot;sommaire_ancre&quot;&gt; &lt;/a&gt; R&#233;f&#233;rencer les images dans le mail &lt;/h3&gt;
&lt;p&gt;Afin d'ins&#233;rer les images dans le mail, il convient d'assigner &#224; chaque image une r&#233;f&#233;rence et indiquer dans le texte la r&#233;f&#233;rence. On appellera cette r&#233;f&#233;rence le &#171; CID &#187; [&lt;a href='#nb2-2' class='spip_note' rel='footnote' title='Content-ID' id='nh2-2'&gt;2&lt;/a&gt;].&lt;/p&gt; &lt;p&gt;On pars du principe que vous avez poss&#233;dez d&#233;j&#224; une liste des images de votre message HTML dans une variable nomm&#233;e &lt;strong&gt;$imgListe&lt;/strong&gt;( sinon il faudra trouver d'autre moyen comme preg_match_all, ou alors un listing de r&#233;pertoire si jamais toutes les images de votre mail se retrouve &#171; par chance &#187; dans un m&#234;me dossier. )&lt;/p&gt; &lt;p&gt;On va donc assigner &#224; chaque image un identifiant nomm&#233; &quot;image-*&quot; o&#249; * sera remplac&#233; par l'indice du tableau correspondant &#224; cette image, et on remplacera l'occurence de cette image dans le contenu du mail ( symbolis&#233; ici par &lt;strong&gt;$content&lt;/strong&gt; ) par cet identifiant.&lt;/p&gt; &lt;p&gt;&lt;code&gt;&lt;span style=&quot;color: #000000&quot;&gt;
&lt;span style=&quot;color: #0000BB&quot;&gt;&lt;?php&lt;br /&gt; &lt;/span&gt;&lt;span style=&quot;color: #007700&quot;&gt;foreach(&lt;/span&gt;&lt;span style=&quot;color: #0000BB&quot;&gt;$imgListe &lt;/span&gt;&lt;span style=&quot;color: #007700&quot;&gt;as &lt;/span&gt;&lt;span style=&quot;color: #0000BB&quot;&gt;$k &lt;/span&gt;&lt;span style=&quot;color: #007700&quot;&gt;=&gt; &lt;/span&gt;&lt;span style=&quot;color: #0000BB&quot;&gt;$v&lt;/span&gt;&lt;span style=&quot;color: #007700&quot;&gt;){&lt;br /&gt; &lt;/span&gt;&lt;span style=&quot;color: #0000BB&quot;&gt;$content &lt;/span&gt;&lt;span style=&quot;color: #007700&quot;&gt;= &lt;/span&gt;&lt;span style=&quot;color: #0000BB&quot;&gt;str_replace&lt;/span&gt;&lt;span style=&quot;color: #007700&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color: #0000BB&quot;&gt;$v&lt;/span&gt;&lt;span style=&quot;color: #007700&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color: #DD0000&quot;&gt;'cid:image'&lt;/span&gt;&lt;span style=&quot;color: #007700&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color: #0000BB&quot;&gt;$k&lt;/span&gt;&lt;span style=&quot;color: #007700&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color: #0000BB&quot;&gt;$content&lt;/span&gt;&lt;span style=&quot;color: #007700&quot;&gt;);&lt;br /&gt; }&lt;br /&gt;&lt;/span&gt;&lt;span style=&quot;color: #0000BB&quot;&gt;?&gt;&lt;/span&gt;
&lt;/span&gt;
&lt;/code&gt;&lt;/p&gt; &lt;p&gt;++++&lt;/p&gt; &lt;h3 class=&quot;spip&quot; id=&quot;outil_sommaire_3&quot;&gt;&lt;a title=&quot;Sommaire&quot; href=&quot;http://blog.6tech.net/spip.php?page=backend#outil_sommaire&quot; class=&quot;sommaire_ancre&quot;&gt; &lt;/a&gt; Renseigner le corps du message &lt;/h3&gt;
&lt;p&gt;Avant derni&#232;re &#233;tape : sp&#233;cifier le corps du message transform&#233; dans la partie pr&#233;c&#233;dente. Il est important de sp&#233;cifier le &lt;a href=&quot;http://fr.wikipedia.org/wiki/Type_MIME&quot; class='spip_out' rel='external'&gt;type mime&lt;/a&gt; [&lt;a href='#nb2-3' class='spip_note' rel='footnote' title='A ne pas confondre avec le protocole MIME' id='nh2-3'&gt;3&lt;/a&gt;] du contenu ( text/html ) et son encodage.&lt;/p&gt; &lt;p&gt;&lt;code&gt;&lt;span style=&quot;color: #000000&quot;&gt;
&lt;span style=&quot;color: #0000BB&quot;&gt;&lt;?php&lt;br /&gt; $msg &lt;/span&gt;&lt;span style=&quot;color: #007700&quot;&gt;= &lt;/span&gt;&lt;span style=&quot;color: #DD0000&quot;&gt;&quot;Content-Type: text/html; charset=\&quot;iso-8859-1\&quot;\r\n&quot;&lt;/span&gt;&lt;span style=&quot;color: #007700&quot;&gt;;&lt;br /&gt; &lt;/span&gt;&lt;span style=&quot;color: #0000BB&quot;&gt;$msg &lt;/span&gt;&lt;span style=&quot;color: #007700&quot;&gt;.= &lt;/span&gt;&lt;span style=&quot;color: #DD0000&quot;&gt;&quot;Content-Transfer-Encoding:8bit\r\n&quot;&lt;/span&gt;&lt;span style=&quot;color: #007700&quot;&gt;;&lt;br /&gt; &lt;/span&gt;&lt;span style=&quot;color: #0000BB&quot;&gt;$msg &lt;/span&gt;&lt;span style=&quot;color: #007700&quot;&gt;.= &lt;/span&gt;&lt;span style=&quot;color: #DD0000&quot;&gt;&quot;\r\n&quot;&lt;/span&gt;&lt;span style=&quot;color: #007700&quot;&gt;;&lt;br /&gt; &lt;/span&gt;&lt;span style=&quot;color: #0000BB&quot;&gt;$msg &lt;/span&gt;&lt;span style=&quot;color: #007700&quot;&gt;.= &lt;/span&gt;&lt;span style=&quot;color: #0000BB&quot;&gt;$content&lt;/span&gt;&lt;span style=&quot;color: #007700&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color: #DD0000&quot;&gt;&quot;\r\n&quot;&lt;/span&gt;&lt;span style=&quot;color: #007700&quot;&gt;;&lt;br /&gt; &lt;/span&gt;&lt;span style=&quot;color: #0000BB&quot;&gt;$msg &lt;/span&gt;&lt;span style=&quot;color: #007700&quot;&gt;.= &lt;/span&gt;&lt;span style=&quot;color: #DD0000&quot;&gt;&quot;\r\n&quot;&lt;/span&gt;&lt;span style=&quot;color: #007700&quot;&gt;;&lt;br /&gt;&lt;/span&gt;&lt;span style=&quot;color: #0000BB&quot;&gt;?&gt;&lt;/span&gt;
&lt;/span&gt;
&lt;/code&gt;&lt;/p&gt; &lt;h3 class=&quot;spip&quot; id=&quot;outil_sommaire_4&quot;&gt;&lt;a title=&quot;Sommaire&quot; href=&quot;http://blog.6tech.net/spip.php?page=backend#outil_sommaire&quot; class=&quot;sommaire_ancre&quot;&gt; &lt;/a&gt; Attacher les images &lt;/h3&gt;
&lt;p&gt;Voici la derni&#232;re &#233;tape avant l'envoi du mail : attacher les images. On consid&#232;re toujours que vous avez un tableau contenant les noms des images de votre mail. On va donc cr&#233;er pour chaque item de ce tableau une entr&#233;e dans le mail gr&#226;ce &#224; cete fonction pr&#233;alablement cr&#233;&#233;e :&lt;/p&gt; &lt;p&gt;&lt;code&gt;&lt;span style=&quot;color: #000000&quot;&gt;
&lt;span style=&quot;color: #0000BB&quot;&gt;&lt;?php&lt;br /&gt; &lt;/span&gt;&lt;span style=&quot;color: #FF8000&quot;&gt;# fonction qui va g&#233;n&#233;rer le texte des images du mail&lt;br /&gt; &lt;/span&gt;&lt;span style=&quot;color: #007700&quot;&gt;function &lt;/span&gt;&lt;span style=&quot;color: #0000BB&quot;&gt;buildImageContent&lt;/span&gt;&lt;span style=&quot;color: #007700&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color: #0000BB&quot;&gt;$file&lt;/span&gt;&lt;span style=&quot;color: #007700&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color: #0000BB&quot;&gt;$key&lt;/span&gt;&lt;span style=&quot;color: #007700&quot;&gt;){&lt;br /&gt; &lt;/span&gt;&lt;span style=&quot;color: #0000BB&quot;&gt;$fp &lt;/span&gt;&lt;span style=&quot;color: #007700&quot;&gt;= &lt;/span&gt;&lt;span style=&quot;color: #0000BB&quot;&gt;fopen&lt;/span&gt;&lt;span style=&quot;color: #007700&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color: #0000BB&quot;&gt;$file&lt;/span&gt;&lt;span style=&quot;color: #007700&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color: #DD0000&quot;&gt;'r'&lt;/span&gt;&lt;span style=&quot;color: #007700&quot;&gt;);&lt;br /&gt; &lt;/span&gt;&lt;span style=&quot;color: #0000BB&quot;&gt;$attached &lt;/span&gt;&lt;span style=&quot;color: #007700&quot;&gt;= &lt;/span&gt;&lt;span style=&quot;color: #0000BB&quot;&gt;fread&lt;/span&gt;&lt;span style=&quot;color: #007700&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color: #0000BB&quot;&gt;$fp&lt;/span&gt;&lt;span style=&quot;color: #007700&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color: #0000BB&quot;&gt;filesize&lt;/span&gt;&lt;span style=&quot;color: #007700&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color: #0000BB&quot;&gt;$file&lt;/span&gt;&lt;span style=&quot;color: #007700&quot;&gt;));&lt;br /&gt; &lt;/span&gt;&lt;span style=&quot;color: #0000BB&quot;&gt;fclose&lt;/span&gt;&lt;span style=&quot;color: #007700&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color: #0000BB&quot;&gt;$fp&lt;/span&gt;&lt;span style=&quot;color: #007700&quot;&gt;);&lt;br /&gt; &lt;/span&gt;&lt;span style=&quot;color: #0000BB&quot;&gt;$attached &lt;/span&gt;&lt;span style=&quot;color: #007700&quot;&gt;= &lt;/span&gt;&lt;span style=&quot;color: #0000BB&quot;&gt;chunk_split&lt;/span&gt;&lt;span style=&quot;color: #007700&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color: #0000BB&quot;&gt;base64_encode&lt;/span&gt;&lt;span style=&quot;color: #007700&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color: #0000BB&quot;&gt;$attached&lt;/span&gt;&lt;span style=&quot;color: #007700&quot;&gt;));&lt;br /&gt;&lt;br /&gt; &lt;/span&gt;&lt;span style=&quot;color: #0000BB&quot;&gt;$msg &lt;/span&gt;&lt;span style=&quot;color: #007700&quot;&gt;= &lt;/span&gt;&lt;span style=&quot;color: #DD0000&quot;&gt;&quot;Content-Type: application/octet-stream; name=\&quot;$file\&quot;\r\n&quot;&lt;/span&gt;&lt;span style=&quot;color: #007700&quot;&gt;;&lt;br /&gt; &lt;/span&gt;&lt;span style=&quot;color: #0000BB&quot;&gt;$msg &lt;/span&gt;&lt;span style=&quot;color: #007700&quot;&gt;.= &lt;/span&gt;&lt;span style=&quot;color: #DD0000&quot;&gt;&quot;Content-Transfer-Encoding: base64\r\n&quot;&lt;/span&gt;&lt;span style=&quot;color: #007700&quot;&gt;;&lt;br /&gt; &lt;/span&gt;&lt;span style=&quot;color: #0000BB&quot;&gt;$msg &lt;/span&gt;&lt;span style=&quot;color: #007700&quot;&gt;.= &lt;/span&gt;&lt;span style=&quot;color: #DD0000&quot;&gt;&quot;Content-ID: &lt;image$key&gt;\r\n&quot;&lt;/span&gt;&lt;span style=&quot;color: #007700&quot;&gt;;&lt;br /&gt; &lt;/span&gt;&lt;span style=&quot;color: #0000BB&quot;&gt;$msg &lt;/span&gt;&lt;span style=&quot;color: #007700&quot;&gt;.= &lt;/span&gt;&lt;span style=&quot;color: #DD0000&quot;&gt;&quot;\r\n&quot;&lt;/span&gt;&lt;span style=&quot;color: #007700&quot;&gt;;&lt;br /&gt; &lt;/span&gt;&lt;span style=&quot;color: #0000BB&quot;&gt;$msg &lt;/span&gt;&lt;span style=&quot;color: #007700&quot;&gt;.= &lt;/span&gt;&lt;span style=&quot;color: #0000BB&quot;&gt;$attached &lt;/span&gt;&lt;span style=&quot;color: #007700&quot;&gt;. &lt;/span&gt;&lt;span style=&quot;color: #DD0000&quot;&gt;&quot;\r\n&quot;&lt;/span&gt;&lt;span style=&quot;color: #007700&quot;&gt;;&lt;br /&gt; &lt;/span&gt;&lt;span style=&quot;color: #0000BB&quot;&gt;$msg &lt;/span&gt;&lt;span style=&quot;color: #007700&quot;&gt;.= &lt;/span&gt;&lt;span style=&quot;color: #DD0000&quot;&gt;&quot;\r\n\r\n&quot;&lt;/span&gt;&lt;span style=&quot;color: #007700&quot;&gt;;&lt;br /&gt;&lt;br /&gt; return &lt;/span&gt;&lt;span style=&quot;color: #0000BB&quot;&gt;$msg&lt;/span&gt;&lt;span style=&quot;color: #007700&quot;&gt;;&lt;br /&gt; }&lt;br /&gt;&lt;/span&gt;&lt;span style=&quot;color: #0000BB&quot;&gt;?&gt;&lt;/span&gt;
&lt;/span&gt;
&lt;/code&gt;&lt;/p&gt; &lt;p&gt;Cette fonction r&#233;cup&#232;re le contenu de l'image dans une variable, segmente ce contenu en ligne de 76 octets apr&#232;s l'avoir encoder en MIME base64 ( pour les syst&#232;mes qui ne g&#232;rent pas correctement les 8bits ), sp&#233;cifie quelle est la r&#233;f&#233;rence de cette image et indique le contenu de l'image. Il est important de toujours mettre une ligne vide entre des ent&#234;tes et le contenu de la partie.&lt;/p&gt; &lt;p&gt;&lt;strong&gt; /!\ Ne pas oublier de s&#233;parer chaque partie du mail par le d&#233;limiteur &lt;/strong&gt;&lt;/p&gt; &lt;p&gt;++++&lt;/p&gt; &lt;h3 class=&quot;spip&quot; id=&quot;outil_sommaire_5&quot;&gt;&lt;a title=&quot;Sommaire&quot; href=&quot;http://blog.6tech.net/spip.php?page=backend#outil_sommaire&quot; class=&quot;sommaire_ancre&quot;&gt; &lt;/a&gt; Exemple &lt;/h3&gt;
&lt;p&gt;Une fois cette fonction d&#233;clar&#233;e, vous pouvez facilement cr&#233;er le message. Voici le code dans son int&#233;gralit&#233; :&lt;/p&gt; &lt;p&gt;&lt;code&gt;&lt;span style=&quot;color: #000000&quot;&gt;
&lt;span style=&quot;color: #0000BB&quot;&gt;&lt;?php&lt;br /&gt;&lt;br /&gt; &lt;/span&gt;&lt;span style=&quot;color: #FF8000&quot;&gt;# fonction qui va g&#233;n&#233;rer le texte des images du mail&lt;br /&gt; &lt;/span&gt;&lt;span style=&quot;color: #007700&quot;&gt;function &lt;/span&gt;&lt;span style=&quot;color: #0000BB&quot;&gt;buildImageContent&lt;/span&gt;&lt;span style=&quot;color: #007700&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color: #0000BB&quot;&gt;$file&lt;/span&gt;&lt;span style=&quot;color: #007700&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color: #0000BB&quot;&gt;$key&lt;/span&gt;&lt;span style=&quot;color: #007700&quot;&gt;){&lt;br /&gt; &lt;/span&gt;&lt;span style=&quot;color: #0000BB&quot;&gt;$fp &lt;/span&gt;&lt;span style=&quot;color: #007700&quot;&gt;= &lt;/span&gt;&lt;span style=&quot;color: #0000BB&quot;&gt;fopen&lt;/span&gt;&lt;span style=&quot;color: #007700&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color: #0000BB&quot;&gt;$file&lt;/span&gt;&lt;span style=&quot;color: #007700&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color: #DD0000&quot;&gt;'r'&lt;/span&gt;&lt;span style=&quot;color: #007700&quot;&gt;);&lt;br /&gt; &lt;/span&gt;&lt;span style=&quot;color: #0000BB&quot;&gt;$attached &lt;/span&gt;&lt;span style=&quot;color: #007700&quot;&gt;= &lt;/span&gt;&lt;span style=&quot;color: #0000BB&quot;&gt;fread&lt;/span&gt;&lt;span style=&quot;color: #007700&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color: #0000BB&quot;&gt;$fp&lt;/span&gt;&lt;span style=&quot;color: #007700&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color: #0000BB&quot;&gt;filesize&lt;/span&gt;&lt;span style=&quot;color: #007700&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color: #0000BB&quot;&gt;$file&lt;/span&gt;&lt;span style=&quot;color: #007700&quot;&gt;));&lt;br /&gt; &lt;/span&gt;&lt;span style=&quot;color: #0000BB&quot;&gt;fclose&lt;/span&gt;&lt;span style=&quot;color: #007700&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color: #0000BB&quot;&gt;$fp&lt;/span&gt;&lt;span style=&quot;color: #007700&quot;&gt;);&lt;br /&gt; &lt;/span&gt;&lt;span style=&quot;color: #0000BB&quot;&gt;$attached &lt;/span&gt;&lt;span style=&quot;color: #007700&quot;&gt;= &lt;/span&gt;&lt;span style=&quot;color: #0000BB&quot;&gt;chunk_split&lt;/span&gt;&lt;span style=&quot;color: #007700&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color: #0000BB&quot;&gt;base64_encode&lt;/span&gt;&lt;span style=&quot;color: #007700&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color: #0000BB&quot;&gt;$attached&lt;/span&gt;&lt;span style=&quot;color: #007700&quot;&gt;));&lt;br /&gt;&lt;br /&gt; &lt;/span&gt;&lt;span style=&quot;color: #0000BB&quot;&gt;$msg &lt;/span&gt;&lt;span style=&quot;color: #007700&quot;&gt;= &lt;/span&gt;&lt;span style=&quot;color: #DD0000&quot;&gt;&quot;Content-Type: application/octet-stream; name=\&quot;$file\&quot;\r\n&quot;&lt;/span&gt;&lt;span style=&quot;color: #007700&quot;&gt;;&lt;br /&gt; &lt;/span&gt;&lt;span style=&quot;color: #0000BB&quot;&gt;$msg &lt;/span&gt;&lt;span style=&quot;color: #007700&quot;&gt;.= &lt;/span&gt;&lt;span style=&quot;color: #DD0000&quot;&gt;&quot;Content-Transfer-Encoding: base64\r\n&quot;&lt;/span&gt;&lt;span style=&quot;color: #007700&quot;&gt;;&lt;br /&gt; &lt;/span&gt;&lt;span style=&quot;color: #0000BB&quot;&gt;$msg &lt;/span&gt;&lt;span style=&quot;color: #007700&quot;&gt;.= &lt;/span&gt;&lt;span style=&quot;color: #DD0000&quot;&gt;&quot;Content-ID: &lt;image$key&gt;\r\n&quot;&lt;/span&gt;&lt;span style=&quot;color: #007700&quot;&gt;;&lt;br /&gt; &lt;/span&gt;&lt;span style=&quot;color: #0000BB&quot;&gt;$msg &lt;/span&gt;&lt;span style=&quot;color: #007700&quot;&gt;.= &lt;/span&gt;&lt;span style=&quot;color: #DD0000&quot;&gt;&quot;\r\n&quot;&lt;/span&gt;&lt;span style=&quot;color: #007700&quot;&gt;;&lt;br /&gt; &lt;/span&gt;&lt;span style=&quot;color: #0000BB&quot;&gt;$msg &lt;/span&gt;&lt;span style=&quot;color: #007700&quot;&gt;.= &lt;/span&gt;&lt;span style=&quot;color: #0000BB&quot;&gt;$attached &lt;/span&gt;&lt;span style=&quot;color: #007700&quot;&gt;. &lt;/span&gt;&lt;span style=&quot;color: #DD0000&quot;&gt;&quot;\r\n&quot;&lt;/span&gt;&lt;span style=&quot;color: #007700&quot;&gt;;&lt;br /&gt; &lt;/span&gt;&lt;span style=&quot;color: #0000BB&quot;&gt;$msg &lt;/span&gt;&lt;span style=&quot;color: #007700&quot;&gt;.= &lt;/span&gt;&lt;span style=&quot;color: #DD0000&quot;&gt;&quot;\r\n\r\n&quot;&lt;/span&gt;&lt;span style=&quot;color: #007700&quot;&gt;;&lt;br /&gt;&lt;br /&gt; return &lt;/span&gt;&lt;span style=&quot;color: #0000BB&quot;&gt;$msg&lt;/span&gt;&lt;span style=&quot;color: #007700&quot;&gt;;&lt;br /&gt; }&lt;br /&gt;&lt;br /&gt;&lt;/span&gt;&lt;span style=&quot;color: #FF8000&quot;&gt;# On d&#233;finit le d&#233;limiteur&lt;br /&gt;&lt;/span&gt;&lt;span style=&quot;color: #0000BB&quot;&gt;$delimiteur &lt;/span&gt;&lt;span style=&quot;color: #007700&quot;&gt;= &lt;/span&gt;&lt;span style=&quot;color: #DD0000&quot;&gt;'--'&lt;/span&gt;&lt;span style=&quot;color: #007700&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color: #DD0000&quot;&gt;'---='&lt;/span&gt;&lt;span style=&quot;color: #007700&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color: #0000BB&quot;&gt;md5&lt;/span&gt;&lt;span style=&quot;color: #007700&quot;&gt;( &lt;/span&gt;&lt;span style=&quot;color: #0000BB&quot;&gt;uniqid&lt;/span&gt;&lt;span style=&quot;color: #007700&quot;&gt;( &lt;/span&gt;&lt;span style=&quot;color: #0000BB&quot;&gt;rand&lt;/span&gt;&lt;span style=&quot;color: #007700&quot;&gt;() ) );&lt;br /&gt;&lt;br /&gt;&lt;/span&gt;&lt;span style=&quot;color: #FF8000&quot;&gt;# Le contenu HTML du message, le destinataire, l'envoyeur, et le sujet &lt;br /&gt;&lt;/span&gt;&lt;span style=&quot;color: #0000BB&quot;&gt;$content &lt;/span&gt;&lt;span style=&quot;color: #007700&quot;&gt;= &lt;/span&gt;&lt;span style=&quot;color: #DD0000&quot;&gt;'mon message en html'&lt;/span&gt;&lt;span style=&quot;color: #007700&quot;&gt;;&lt;br /&gt;&lt;/span&gt;&lt;span style=&quot;color: #0000BB&quot;&gt;$to &lt;/span&gt;&lt;span style=&quot;color: #007700&quot;&gt;= &lt;/span&gt;&lt;span style=&quot;color: #DD0000&quot;&gt;'you@spam.com'&lt;/span&gt;&lt;span style=&quot;color: #007700&quot;&gt;;&lt;br /&gt;&lt;/span&gt;&lt;span style=&quot;color: #0000BB&quot;&gt;$from &lt;/span&gt;&lt;span style=&quot;color: #007700&quot;&gt;= &lt;/span&gt;&lt;span style=&quot;color: #DD0000&quot;&gt;'me@spam.com'&lt;/span&gt;&lt;span style=&quot;color: #007700&quot;&gt;;&lt;br /&gt;&lt;/span&gt;&lt;span style=&quot;color: #0000BB&quot;&gt;$subject &lt;/span&gt;&lt;span style=&quot;color: #007700&quot;&gt;= &lt;/span&gt;&lt;span style=&quot;color: #DD0000&quot;&gt;'Happy to be spamed'&lt;/span&gt;&lt;span style=&quot;color: #007700&quot;&gt;;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;/span&gt;&lt;span style=&quot;color: #FF8000&quot;&gt;# la liste des images du message&lt;br /&gt;&lt;/span&gt;&lt;span style=&quot;color: #0000BB&quot;&gt;$imgListe &lt;/span&gt;&lt;span style=&quot;color: #007700&quot;&gt;= array(&lt;/span&gt;&lt;span style=&quot;color: #DD0000&quot;&gt;'monImage.gif'&lt;/span&gt;&lt;span style=&quot;color: #007700&quot;&gt;);&lt;br /&gt;&lt;br /&gt;&lt;/span&gt;&lt;span style=&quot;color: #FF8000&quot;&gt;# Les ent&#234;tes du mail &lt;br /&gt;&lt;/span&gt;&lt;span style=&quot;color: #0000BB&quot;&gt;$headers &lt;/span&gt;&lt;span style=&quot;color: #007700&quot;&gt;= &lt;/span&gt;&lt;span style=&quot;color: #DD0000&quot;&gt;&quot;MIME-Version: 1.0\r\n&quot;&lt;/span&gt;&lt;span style=&quot;color: #007700&quot;&gt;;&lt;br /&gt;&lt;/span&gt;&lt;span style=&quot;color: #0000BB&quot;&gt;$headers &lt;/span&gt;&lt;span style=&quot;color: #007700&quot;&gt;.= &lt;/span&gt;&lt;span style=&quot;color: #DD0000&quot;&gt;&quot;Content-Type: multipart/related; boundary=\&quot;$delimiteur\&quot;\r\n&quot;&lt;/span&gt;&lt;span style=&quot;color: #007700&quot;&gt;;&lt;br /&gt;&lt;/span&gt;&lt;span style=&quot;color: #0000BB&quot;&gt;$headers &lt;/span&gt;&lt;span style=&quot;color: #007700&quot;&gt;.= &lt;/span&gt;&lt;span style=&quot;color: #DD0000&quot;&gt;&quot;Reply-to: $from\r\n&quot;&lt;/span&gt;&lt;span style=&quot;color: #007700&quot;&gt;;&lt;br /&gt;&lt;/span&gt;&lt;span style=&quot;color: #0000BB&quot;&gt;$headers &lt;/span&gt;&lt;span style=&quot;color: #007700&quot;&gt;.= &lt;/span&gt;&lt;span style=&quot;color: #DD0000&quot;&gt;&quot;From: $from\r\n&quot;&lt;/span&gt;&lt;span style=&quot;color: #007700&quot;&gt;;&lt;br /&gt;&lt;/span&gt;&lt;span style=&quot;color: #0000BB&quot;&gt;$headers &lt;/span&gt;&lt;span style=&quot;color: #007700&quot;&gt;.= &lt;/span&gt;&lt;span style=&quot;color: #DD0000&quot;&gt;&quot;\r\n&quot;&lt;/span&gt;&lt;span style=&quot;color: #007700&quot;&gt;;&lt;br /&gt;&lt;br /&gt;&lt;/span&gt;&lt;span style=&quot;color: #FF8000&quot;&gt;# On va transformer le HTML du mail&lt;br /&gt;&lt;/span&gt;&lt;span style=&quot;color: #007700&quot;&gt;foreach(&lt;/span&gt;&lt;span style=&quot;color: #0000BB&quot;&gt;$imgListe &lt;/span&gt;&lt;span style=&quot;color: #007700&quot;&gt;as &lt;/span&gt;&lt;span style=&quot;color: #0000BB&quot;&gt;$k &lt;/span&gt;&lt;span style=&quot;color: #007700&quot;&gt;=&gt; &lt;/span&gt;&lt;span style=&quot;color: #0000BB&quot;&gt;$v&lt;/span&gt;&lt;span style=&quot;color: #007700&quot;&gt;){&lt;br /&gt; &lt;/span&gt;&lt;span style=&quot;color: #0000BB&quot;&gt;$content &lt;/span&gt;&lt;span style=&quot;color: #007700&quot;&gt;= &lt;/span&gt;&lt;span style=&quot;color: #0000BB&quot;&gt;str_replace&lt;/span&gt;&lt;span style=&quot;color: #007700&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color: #0000BB&quot;&gt;$v&lt;/span&gt;&lt;span style=&quot;color: #007700&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color: #DD0000&quot;&gt;'cid:image'&lt;/span&gt;&lt;span style=&quot;color: #007700&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color: #0000BB&quot;&gt;$k&lt;/span&gt;&lt;span style=&quot;color: #007700&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color: #0000BB&quot;&gt;$content&lt;/span&gt;&lt;span style=&quot;color: #007700&quot;&gt;);&lt;br /&gt; }&lt;br /&gt;&lt;br /&gt;&lt;/span&gt;&lt;span style=&quot;color: #FF8000&quot;&gt;# Le contenu du mail avec le HTML transform&#233;&lt;br /&gt;&lt;/span&gt;&lt;span style=&quot;color: #0000BB&quot;&gt;$msg &lt;/span&gt;&lt;span style=&quot;color: #007700&quot;&gt;= &lt;/span&gt;&lt;span style=&quot;color: #DD0000&quot;&gt;&quot;Content-Type: text/html; charset=\&quot;iso-8859-1\&quot;\r\n&quot;&lt;/span&gt;&lt;span style=&quot;color: #007700&quot;&gt;;&lt;br /&gt;&lt;/span&gt;&lt;span style=&quot;color: #0000BB&quot;&gt;$msg &lt;/span&gt;&lt;span style=&quot;color: #007700&quot;&gt;.= &lt;/span&gt;&lt;span style=&quot;color: #DD0000&quot;&gt;&quot;Content-Transfer-Encoding:8bit\r\n&quot;&lt;/span&gt;&lt;span style=&quot;color: #007700&quot;&gt;;&lt;br /&gt;&lt;/span&gt;&lt;span style=&quot;color: #0000BB&quot;&gt;$msg &lt;/span&gt;&lt;span style=&quot;color: #007700&quot;&gt;.= &lt;/span&gt;&lt;span style=&quot;color: #DD0000&quot;&gt;&quot;\r\n&quot;&lt;/span&gt;&lt;span style=&quot;color: #007700&quot;&gt;;&lt;br /&gt;&lt;/span&gt;&lt;span style=&quot;color: #0000BB&quot;&gt;$msg &lt;/span&gt;&lt;span style=&quot;color: #007700&quot;&gt;.= &lt;/span&gt;&lt;span style=&quot;color: #0000BB&quot;&gt;$content&lt;/span&gt;&lt;span style=&quot;color: #007700&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color: #DD0000&quot;&gt;&quot;\r\n&quot;&lt;/span&gt;&lt;span style=&quot;color: #007700&quot;&gt;;&lt;br /&gt;&lt;/span&gt;&lt;span style=&quot;color: #0000BB&quot;&gt;$msg &lt;/span&gt;&lt;span style=&quot;color: #007700&quot;&gt;.= &lt;/span&gt;&lt;span style=&quot;color: #DD0000&quot;&gt;&quot;\r\n&quot;&lt;/span&gt;&lt;span style=&quot;color: #007700&quot;&gt;;&lt;br /&gt;&lt;br /&gt;&lt;/span&gt;&lt;span style=&quot;color: #FF8000&quot;&gt;# on attache toutes les images du mail&lt;br /&gt;&lt;/span&gt;&lt;span style=&quot;color: #007700&quot;&gt;foreach(&lt;/span&gt;&lt;span style=&quot;color: #0000BB&quot;&gt;$imgListe &lt;/span&gt;&lt;span style=&quot;color: #007700&quot;&gt;as &lt;/span&gt;&lt;span style=&quot;color: #0000BB&quot;&gt;$k &lt;/span&gt;&lt;span style=&quot;color: #007700&quot;&gt;=&gt; &lt;/span&gt;&lt;span style=&quot;color: #0000BB&quot;&gt;$v&lt;/span&gt;&lt;span style=&quot;color: #007700&quot;&gt;){&lt;br /&gt; &lt;/span&gt;&lt;span style=&quot;color: #0000BB&quot;&gt;$msg &lt;/span&gt;&lt;span style=&quot;color: #007700&quot;&gt;.= &lt;/span&gt;&lt;span style=&quot;color: #DD0000&quot;&gt;'--'&lt;/span&gt;&lt;span style=&quot;color: #007700&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color: #0000BB&quot;&gt;$delimiteur&lt;/span&gt;&lt;span style=&quot;color: #007700&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color: #DD0000&quot;&gt;&quot;\r\n&quot;&lt;/span&gt;&lt;span style=&quot;color: #007700&quot;&gt;;&lt;br /&gt; &lt;/span&gt;&lt;span style=&quot;color: #0000BB&quot;&gt;$msg &lt;/span&gt;&lt;span style=&quot;color: #007700&quot;&gt;. = &lt;/span&gt;&lt;span style=&quot;color: #0000BB&quot;&gt;buildImageContent&lt;/span&gt;&lt;span style=&quot;color: #007700&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color: #0000BB&quot;&gt;$v&lt;/span&gt;&lt;span style=&quot;color: #007700&quot;&gt;,&lt;/span&gt;&lt;span style=&quot;color: #0000BB&quot;&gt;$k&lt;/span&gt;&lt;span style=&quot;color: #007700&quot;&gt;);&lt;br /&gt; }&lt;br /&gt; &lt;br /&gt;&lt;/span&gt;&lt;span style=&quot;color: #FF8000&quot;&gt;# Une derni&#232;re petite ligne &lt;br /&gt;&lt;/span&gt;&lt;span style=&quot;color: #0000BB&quot;&gt;$msg &lt;/span&gt;&lt;span style=&quot;color: #007700&quot;&gt;.= &lt;/span&gt;&lt;span style=&quot;color: #DD0000&quot;&gt;'--'&lt;/span&gt;&lt;span style=&quot;color: #007700&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color: #0000BB&quot;&gt;$delimiteur&lt;/span&gt;&lt;span style=&quot;color: #007700&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color: #DD0000&quot;&gt;&quot;\r\n&quot;&lt;/span&gt;&lt;span style=&quot;color: #007700&quot;&gt;;&lt;br /&gt;&lt;br /&gt;&lt;/span&gt;&lt;span style=&quot;color: #FF8000&quot;&gt;# Et on envois le mail&lt;br /&gt;&lt;/span&gt;&lt;span style=&quot;color: #0000BB&quot;&gt;mail&lt;/span&gt;&lt;span style=&quot;color: #007700&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color: #0000BB&quot;&gt;$to&lt;/span&gt;&lt;span style=&quot;color: #007700&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color: #0000BB&quot;&gt;$subject&lt;/span&gt;&lt;span style=&quot;color: #007700&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color: #0000BB&quot;&gt;$msg&lt;/span&gt;&lt;span style=&quot;color: #007700&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color: #0000BB&quot;&gt;$headers&lt;/span&gt;&lt;span style=&quot;color: #007700&quot;&gt;);&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;/span&gt;&lt;span style=&quot;color: #0000BB&quot;&gt;?&gt;&lt;/span&gt;
&lt;/span&gt;
&lt;/code&gt;&lt;/p&gt;&lt;/div&gt;
		&lt;hr /&gt;
		&lt;div class='rss_notes'&gt;&lt;p&gt;&lt;span class=&quot;csfoo htmla&quot;&gt;&lt;/span&gt;[&lt;a href='#nh2-1' id='nb2-1' class='spip_note' title='Notes 2-1' rev='footnote'&gt;1&lt;/a&gt;] &lt;span class=&quot;csfoo htmlb&quot;&gt;&lt;/span&gt;permet de sp&#233;cifier que les diff&#233;rentes parties du message devrait &#234;tre trait&#233;es comme un tout&lt;/p&gt; &lt;p&gt;&lt;span class=&quot;csfoo htmla&quot;&gt;&lt;/span&gt;[&lt;a href='#nh2-2' id='nb2-2' class='spip_note' title='Notes 2-2' rev='footnote'&gt;2&lt;/a&gt;] &lt;span class=&quot;csfoo htmlb&quot;&gt;&lt;/span&gt;Content-ID&lt;/p&gt; &lt;p&gt;&lt;span class=&quot;csfoo htmla&quot;&gt;&lt;/span&gt;[&lt;a href='#nh2-3' id='nb2-3' class='spip_note' title='Notes 2-3' rev='footnote'&gt;3&lt;/a&gt;] &lt;span class=&quot;csfoo htmlb&quot;&gt;&lt;/span&gt;A ne pas confondre avec le protocole MIME&lt;/p&gt;&lt;/div&gt;
		
		</content:encoded>


		

	</item>
<item xml:lang="fr">
		<title>Fonction multi-r&#233;sultat</title>
		<link>http://blog.6tech.net/fonction-multi-resultat,40.html</link>
		<guid isPermaLink="true">http://blog.6tech.net/fonction-multi-resultat,40.html</guid>
		<dc:date>2008-04-08T21:07:41Z</dc:date>
		<dc:format>text/html</dc:format>
		<dc:language>fr</dc:language>
		


		<dc:subject>PHP</dc:subject>
		<dc:subject>Fonctions</dc:subject>

		<description>Il arrive souvent lors de construction de fonctions personnalis&#233;es en PHP de vouloir retourner plusieurs variables calcul&#233;es par la fonction en une fois plut&#244;t que de cr&#233;er une fonction diff&#233;rente par traitement. Retour par tableau Cette solution consiste en fait &#224; renvoyer un tableau contenant les diff&#233;rents r&#233;sultats. L'absence de typage en PHP nous permet facilement de renvoyer plusieurs r&#233;sultat de types diff&#233;rents dans une m&#234;me structure. Exemple de retour par tableau On veux pouvoir r&#233;cup&#233;rer (...)

-
&lt;a href="http://blog.6tech.net/-tutoriaux,7-.html" rel="directory"&gt;Tutoriaux&lt;/a&gt;

/ 
&lt;a href="http://blog.6tech.net/+-php,1-+.html" rel="tag"&gt;PHP&lt;/a&gt;, 
&lt;a href="http://blog.6tech.net/+-fonctions,23-+.html" rel="tag"&gt;Fonctions&lt;/a&gt;

		</description>


 <content:encoded>&lt;div class='rss_texte'&gt;&lt;div class=&quot;cs_sommaire cs_sommaire_avec_fond&quot; id=&quot;outil_sommaire&quot;&gt; &lt;div class=&quot;cs_sommaire_inner&quot;&gt; &lt;div class=&quot;cs_sommaire_titre_avec_fond&quot;&gt; Sommaire &lt;/div&gt; &lt;ul&gt; &lt;li&gt;&lt;a title=&quot;Retour par tableau&quot; href=&quot;http://blog.6tech.net/spip.php?page=backend#outil_sommaire_0&quot;&gt;Retour par tableau&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a title=&quot;Le passage par r&#233;f&#233;rence&quot; href=&quot;http://blog.6tech.net/spip.php?page=backend#outil_sommaire_1&quot;&gt;Le passage par r&#233;f&#233;rence&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a title=&quot;La modification par global&quot; href=&quot;http://blog.6tech.net/spip.php?page=backend#outil_sommaire_2&quot;&gt;La modification par global&lt;/a&gt;&lt;/li&gt; &lt;/ul&gt; &lt;/div&gt; &lt;/div&gt;&lt;p&gt;Il arrive souvent lors de construction de fonctions personnalis&#233;es en PHP de vouloir retourner plusieurs variables calcul&#233;es par la fonction en une fois plut&#244;t que de cr&#233;er une fonction diff&#233;rente par traitement.&lt;/p&gt; &lt;h3 class=&quot;spip&quot; id=&quot;outil_sommaire_0&quot;&gt;&lt;a title=&quot;Sommaire&quot; href=&quot;http://blog.6tech.net/spip.php?page=backend#outil_sommaire&quot; class=&quot;sommaire_ancre&quot;&gt; &lt;/a&gt;Retour par tableau&lt;/h3&gt;
&lt;p&gt;Cette solution consiste en fait &#224; renvoyer un tableau contenant les diff&#233;rents r&#233;sultats. L'absence de typage en PHP nous permet facilement de renvoyer plusieurs r&#233;sultat de types diff&#233;rents dans une m&#234;me structure.&lt;/p&gt; &lt;p&gt;&lt;strong&gt;Exemple de retour par tableau&lt;/strong&gt;
&lt;i&gt;On veux pouvoir r&#233;cup&#233;rer les carr&#233;s et les cubes d'un nombre &#224; partir d'une seule fonction&lt;/i&gt;&lt;/p&gt; &lt;p&gt;&lt;code&gt;&lt;span style=&quot;color: #000000&quot;&gt;
&lt;span style=&quot;color: #0000BB&quot;&gt;&lt;?php&lt;br /&gt;unction calcul_puissance&lt;/span&gt;&lt;span style=&quot;color: #007700&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color: #0000BB&quot;&gt;$n&lt;/span&gt;&lt;span style=&quot;color: #007700&quot;&gt;){&lt;br /&gt; &lt;/span&gt;&lt;span style=&quot;color: #0000BB&quot;&gt;$puiss1 &lt;/span&gt;&lt;span style=&quot;color: #007700&quot;&gt;= &lt;/span&gt;&lt;span style=&quot;color: #0000BB&quot;&gt;$n&lt;/span&gt;&lt;span style=&quot;color: #007700&quot;&gt;;&lt;br /&gt; &lt;/span&gt;&lt;span style=&quot;color: #0000BB&quot;&gt;$puiss2 &lt;/span&gt;&lt;span style=&quot;color: #007700&quot;&gt;= &lt;/span&gt;&lt;span style=&quot;color: #0000BB&quot;&gt;$puiss1&lt;/span&gt;&lt;span style=&quot;color: #007700&quot;&gt;*&lt;/span&gt;&lt;span style=&quot;color: #0000BB&quot;&gt;$n&lt;/span&gt;&lt;span style=&quot;color: #007700&quot;&gt;;&lt;br /&gt; &lt;/span&gt;&lt;span style=&quot;color: #0000BB&quot;&gt;$puiss3 &lt;/span&gt;&lt;span style=&quot;color: #007700&quot;&gt;= &lt;/span&gt;&lt;span style=&quot;color: #0000BB&quot;&gt;$puiss2&lt;/span&gt;&lt;span style=&quot;color: #007700&quot;&gt;*&lt;/span&gt;&lt;span style=&quot;color: #0000BB&quot;&gt;$n&lt;/span&gt;&lt;span style=&quot;color: #007700&quot;&gt;;&lt;br /&gt; &lt;/span&gt;&lt;span style=&quot;color: #0000BB&quot;&gt;$table &lt;/span&gt;&lt;span style=&quot;color: #007700&quot;&gt;= array(&lt;/span&gt;&lt;span style=&quot;color: #0000BB&quot;&gt;$puiss1&lt;/span&gt;&lt;span style=&quot;color: #007700&quot;&gt;,&lt;/span&gt;&lt;span style=&quot;color: #0000BB&quot;&gt;$puiss2&lt;/span&gt;&lt;span style=&quot;color: #007700&quot;&gt;,&lt;/span&gt;&lt;span style=&quot;color: #0000BB&quot;&gt;$puiss3&lt;/span&gt;&lt;span style=&quot;color: #007700&quot;&gt;); &lt;/span&gt;&lt;span style=&quot;color: #FF8000&quot;&gt;// cr&#233;er un tableau avec les valeurs $puiss1, $puiss2 et $puiss3 &lt;br /&gt; &lt;/span&gt;&lt;span style=&quot;color: #007700&quot;&gt;return &lt;/span&gt;&lt;span style=&quot;color: #0000BB&quot;&gt;$table&lt;/span&gt;&lt;span style=&quot;color: #007700&quot;&gt;; &lt;/span&gt;&lt;span style=&quot;color: #FF8000&quot;&gt;// retourne le tableau pr&#233;c&#233;demment cr&#233;&#233;&lt;br /&gt;&lt;/span&gt;&lt;span style=&quot;color: #007700&quot;&gt;}&lt;br /&gt;&lt;/span&gt;&lt;span style=&quot;color: #0000BB&quot;&gt;?&gt;&lt;/span&gt;
&lt;/span&gt;
&lt;/code&gt;&lt;/p&gt; &lt;h3 class=&quot;spip&quot; id=&quot;outil_sommaire_1&quot;&gt;&lt;a title=&quot;Sommaire&quot; href=&quot;http://blog.6tech.net/spip.php?page=backend#outil_sommaire&quot; class=&quot;sommaire_ancre&quot;&gt; &lt;/a&gt;Le passage par r&#233;f&#233;rence&lt;/h3&gt;
&lt;p&gt;Vous pouvez modifier directement des variables du script en les passant par r&#233;f&#233;rence &#224; la fonction avec le pr&#233;fix &lt;strong&gt;&amp;&lt;/strong&gt; sur le nom de variable. Toutes modifications effectu&#233;es intra-muraux dans la fonction affectera la variable pass&#233;e en param&#232;tre par r&#233;f&#233;rence &#224; la fonction.&lt;/p&gt; &lt;p&gt;&lt;strong&gt;Exemple de passage par r&#233;f&#233;rence&lt;/strong&gt;&lt;/p&gt; &lt;p&gt;&lt;code&gt;&lt;span style=&quot;color: #000000&quot;&gt;
&lt;span style=&quot;color: #0000BB&quot;&gt;&lt;?php&lt;br /&gt; &lt;/span&gt;&lt;span style=&quot;color: #007700&quot;&gt;function &lt;/span&gt;&lt;span style=&quot;color: #0000BB&quot;&gt;assign_valeur&lt;/span&gt;&lt;span style=&quot;color: #007700&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color: #0000BB&quot;&gt;$var&lt;/span&gt;&lt;span style=&quot;color: #007700&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color: #0000BB&quot;&gt;$value&lt;/span&gt;&lt;span style=&quot;color: #007700&quot;&gt;){&lt;br /&gt; &lt;/span&gt;&lt;span style=&quot;color: #0000BB&quot;&gt;$value &lt;/span&gt;&lt;span style=&quot;color: #007700&quot;&gt;= &lt;/span&gt;&lt;span style=&quot;color: #0000BB&quot;&gt;$var&lt;/span&gt;&lt;span style=&quot;color: #007700&quot;&gt;;&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;&lt;/span&gt;&lt;span style=&quot;color: #0000BB&quot;&gt;$chaine &lt;/span&gt;&lt;span style=&quot;color: #007700&quot;&gt;= &lt;/span&gt;&lt;span style=&quot;color: #DD0000&quot;&gt;'Voici une chaine de test'&lt;/span&gt;&lt;span style=&quot;color: #007700&quot;&gt;;&lt;br /&gt;&lt;/span&gt;&lt;span style=&quot;color: #0000BB&quot;&gt;assign_valeur&lt;/span&gt;&lt;span style=&quot;color: #007700&quot;&gt;(&amp;&lt;/span&gt;&lt;span style=&quot;color: #0000BB&quot;&gt;$chaine&lt;/span&gt;&lt;span style=&quot;color: #007700&quot;&gt;,&lt;/span&gt;&lt;span style=&quot;color: #DD0000&quot;&gt;'2e chaine de test'&lt;/span&gt;&lt;span style=&quot;color: #007700&quot;&gt;);&lt;br /&gt;echo &lt;/span&gt;&lt;span style=&quot;color: #0000BB&quot;&gt;$chaine&lt;/span&gt;&lt;span style=&quot;color: #007700&quot;&gt;;&lt;br /&gt;&lt;/span&gt;&lt;span style=&quot;color: #0000BB&quot;&gt;?&gt;&lt;/span&gt;
&lt;/span&gt;
&lt;/code&gt;&lt;/p&gt; &lt;p&gt;La variable &lt;i&gt;$chaine&lt;/i&gt; contenant une valeur d'origine sera modifi&#233;e directement au niveau du script par la fonction &lt;strong&gt;assign_valeur&lt;/strong&gt; qui lui assignera la valeur contenu dans le deuxi&#232;me param&#232;tre de la fonction ( en l'occurence, &lt;i&gt;echo $chaine&lt;/i&gt; affichera &quot;2e chaine de test&quot; )&lt;/p&gt; &lt;h3 class=&quot;spip&quot; id=&quot;outil_sommaire_2&quot;&gt;&lt;a title=&quot;Sommaire&quot; href=&quot;http://blog.6tech.net/spip.php?page=backend#outil_sommaire&quot; class=&quot;sommaire_ancre&quot;&gt; &lt;/a&gt;La modification par &lt;strong&gt;global&lt;/strong&gt; &lt;/h3&gt;
&lt;p&gt;Une autre solution un peu du m&#234;me genre que la pr&#233;c&#233;dente permet de modifier une variable du script &#224; partir de la fonction. Il faut pour cela sp&#233;cifier avant traitement de la variable par la fonction que la variable est &#224; modifier au niveau du script g&#233;n&#233;ral par le mot clef &lt;strong&gt;global&lt;/strong&gt;&lt;/p&gt; &lt;p&gt;&lt;strong&gt;Exemple de modification par global&lt;/strong&gt;&lt;/p&gt; &lt;p&gt;&lt;code&gt;&lt;span style=&quot;color: #000000&quot;&gt;
&lt;span style=&quot;color: #0000BB&quot;&gt;&lt;?php&lt;br /&gt;&lt;br /&gt;$nb_pizza&lt;/span&gt;&lt;span style=&quot;color: #007700&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color: #0000BB&quot;&gt;0&lt;/span&gt;&lt;span style=&quot;color: #007700&quot;&gt;;&lt;br /&gt;&lt;br /&gt;function &lt;/span&gt;&lt;span style=&quot;color: #0000BB&quot;&gt;ajouter_pizza&lt;/span&gt;&lt;span style=&quot;color: #007700&quot;&gt;(){ &lt;/span&gt;&lt;span style=&quot;color: #FF8000&quot;&gt;// d&#233;claration de la fonction&lt;br /&gt; &lt;/span&gt;&lt;span style=&quot;color: #007700&quot;&gt;global &lt;/span&gt;&lt;span style=&quot;color: #0000BB&quot;&gt;$nb_pizza&lt;/span&gt;&lt;span style=&quot;color: #007700&quot;&gt;;&lt;br /&gt; &lt;/span&gt;&lt;span style=&quot;color: #0000BB&quot;&gt;$nb_pizza &lt;/span&gt;&lt;span style=&quot;color: #007700&quot;&gt;= &lt;/span&gt;&lt;span style=&quot;color: #0000BB&quot;&gt;$nb_pizza&lt;/span&gt;&lt;span style=&quot;color: #007700&quot;&gt;+&lt;/span&gt;&lt;span style=&quot;color: #0000BB&quot;&gt;1&lt;/span&gt;&lt;span style=&quot;color: #007700&quot;&gt;; &lt;/span&gt;&lt;span style=&quot;color: #FF8000&quot;&gt;// it&#233;ration du nombre de pizza&lt;br /&gt;&lt;/span&gt;&lt;span style=&quot;color: #007700&quot;&gt;}&lt;br /&gt;&lt;br /&gt;&lt;/span&gt;&lt;span style=&quot;color: #0000BB&quot;&gt;ajouter_pizza&lt;/span&gt;&lt;span style=&quot;color: #007700&quot;&gt;(); &lt;/span&gt;&lt;span style=&quot;color: #FF8000&quot;&gt;// ajoute une pizza&lt;br /&gt;&lt;/span&gt;&lt;span style=&quot;color: #0000BB&quot;&gt;ajouter_pizza&lt;/span&gt;&lt;span style=&quot;color: #007700&quot;&gt;(); &lt;/span&gt;&lt;span style=&quot;color: #FF8000&quot;&gt;// ajoute une pizza&lt;br /&gt;&lt;br /&gt;&lt;/span&gt;&lt;span style=&quot;color: #007700&quot;&gt;echo &lt;/span&gt;&lt;span style=&quot;color: #DD0000&quot;&gt;&quot;Nombre de pizza(s) : &quot;&lt;/span&gt;&lt;span style=&quot;color: #007700&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color: #0000BB&quot;&gt;$nb_pizza&lt;/span&gt;&lt;span style=&quot;color: #007700&quot;&gt;;&lt;br /&gt;&lt;/span&gt;&lt;span style=&quot;color: #0000BB&quot;&gt;?&gt;&lt;/span&gt;
&lt;/span&gt;
&lt;/code&gt;&lt;/p&gt; &lt;p&gt;R&#233;sultat : &lt;strong&gt;Nombre de pizza(s) : 2 &lt;/strong&gt;&lt;/p&gt; &lt;p&gt;On sp&#233;cifie au niveau de la fonction que la variable $nb_pizza &#224; utiliser n'est pas une nouvelle variable mais bien celle d&#233;finie pr&#233;c&#233;demment au d&#233;but du script. Si jamais vous enlevez le mot clef &lt;strong&gt;global&lt;/strong&gt;, la fonction essayera de cr&#233;er une nouvelle variable et l'incr&#233;mentera de un. Cependant &#224; la sortie de la fonction la variable du m&#234;me nom au niveau du script restera inchang&#233;e et gardera sa valeur initiale : 0&lt;/p&gt;&lt;/div&gt;
		
		</content:encoded>


		

	</item>
<item xml:lang="fr">
		<title>La surcharge de fonctions</title>
		<link>http://blog.6tech.net/la-surcharge-de-fonctions,39.html</link>
		<guid isPermaLink="true">http://blog.6tech.net/la-surcharge-de-fonctions,39.html</guid>
		<dc:date>2008-04-08T21:03:07Z</dc:date>
		<dc:format>text/html</dc:format>
		<dc:language>fr</dc:language>
		


		<dc:subject>PHP</dc:subject>
		<dc:subject>Fonctions</dc:subject>

		<description>&lt;p&gt;Comment palier au manque cruel de PHP sur la surcharge de fonction (inh&#233;rent directement de l'absence de typage de donn&#233;es )&lt;/p&gt;

-
&lt;a href="http://blog.6tech.net/-tutoriaux,7-.html" rel="directory"&gt;Tutoriaux&lt;/a&gt;

/ 
&lt;a href="http://blog.6tech.net/+-php,1-+.html" rel="tag"&gt;PHP&lt;/a&gt;, 
&lt;a href="http://blog.6tech.net/+-fonctions,23-+.html" rel="tag"&gt;Fonctions&lt;/a&gt;

		</description>


 <content:encoded>&lt;div class='rss_texte'&gt;&lt;div class=&quot;cs_sommaire cs_sommaire_avec_fond&quot; id=&quot;outil_sommaire&quot;&gt; &lt;div class=&quot;cs_sommaire_inner&quot;&gt; &lt;div class=&quot;cs_sommaire_titre_avec_fond&quot;&gt; Sommaire &lt;/div&gt; &lt;ul&gt; &lt;li&gt;&lt;a title=&quot;Appel de fonction classique&quot; href=&quot;http://blog.6tech.net/spip.php?page=backend#outil_sommaire_0&quot;&gt;Appel de fonction classique&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a title=&quot;Appel de m&#233;thode d&amp;#39;objet&quot; href=&quot;http://blog.6tech.net/spip.php?page=backend#outil_sommaire_1&quot;&gt;Appel de m&#233;thode d'objet&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a title=&quot;Surchage de getter et setter&quot; href=&quot;http://blog.6tech.net/spip.php?page=backend#outil_sommaire_2&quot;&gt;Surchage de getter et setter&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a title=&quot;Le gestionnaire d&amp;#39;erreur de PHP&quot; href=&quot;http://blog.6tech.net/spip.php?page=backend#outil_sommaire_3&quot;&gt;Le gestionnaire d'erreur (...)&lt;/a&gt;&lt;/li&gt; &lt;/ul&gt; &lt;/div&gt; &lt;/div&gt;&lt;p&gt;Qui n'a jamais voulu cr&#233;er deux fonctions diff&#233;rentes mais avec un profil relativement proche ( m&#234;me nom, mais le dernier param&#232;tre serait un entier suppl&#233;mentaire par exemple) ou alors a d&#233;fini maladroitement la m&#234;me fonction dans plusieurs fichiers mais d&#233;cide de modifier son profil ?&lt;/p&gt; &lt;p&gt;Il existe pour cela plusieurs m&#233;thodes qui d&#233;pendent majoritairement de la structure que vous employez.&lt;/p&gt; &lt;h3 class=&quot;spip&quot; id=&quot;outil_sommaire_0&quot;&gt;&lt;a title=&quot;Sommaire&quot; href=&quot;http://blog.6tech.net/spip.php?page=backend#outil_sommaire&quot; class=&quot;sommaire_ancre&quot;&gt; &lt;/a&gt; Appel de fonction classique &lt;/h3&gt;
&lt;p&gt;Cette solution consiste &#224; cr&#233;er une fonction sans param&#232;tres ( ou avec uniquement les arguments communs &#224; la fonction de base et ses &#233;ventuelles surcharges ) et d'appliquer un traitement diff&#233;rent en fonction du nombre d'arguments pass&#233;s en param&#232;tres gr&#226;ce aux fonctions : &lt;strong&gt;func_get_args()&lt;/strong&gt; et &lt;strong&gt;func_num_args()&lt;/strong&gt;&lt;/p&gt; &lt;p&gt;&lt;strong&gt;Exemple de fonction &#224; nombre d'argument variable&lt;/strong&gt;
On veut r&#233;cup&#233;rer le plus grand nombre parmi les param&#232;tres fournis &#224; la fonction si leur nombre est pair, ou le plus petit si leur nombre est impair.&lt;/p&gt; &lt;p&gt;&lt;code&gt;&lt;span style=&quot;color: #000000&quot;&gt;
&lt;span style=&quot;color: #0000BB&quot;&gt;&lt;?php&lt;br /&gt;&lt;/span&gt;&lt;span style=&quot;color: #007700&quot;&gt;function &lt;/span&gt;&lt;span style=&quot;color: #0000BB&quot;&gt;minMaxFromValue&lt;/span&gt;&lt;span style=&quot;color: #007700&quot;&gt;(){&lt;br /&gt; &lt;/span&gt;&lt;span style=&quot;color: #0000BB&quot;&gt;$argsCount &lt;/span&gt;&lt;span style=&quot;color: #007700&quot;&gt;= &lt;/span&gt;&lt;span style=&quot;color: #0000BB&quot;&gt;func_num_args&lt;/span&gt;&lt;span style=&quot;color: #007700&quot;&gt;();&lt;br /&gt; &lt;/span&gt;&lt;span style=&quot;color: #0000BB&quot;&gt;$argsList &lt;/span&gt;&lt;span style=&quot;color: #007700&quot;&gt;= &lt;/span&gt;&lt;span style=&quot;color: #0000BB&quot;&gt;func_get_args&lt;/span&gt;&lt;span style=&quot;color: #007700&quot;&gt;();&lt;br /&gt; &lt;/span&gt;&lt;span style=&quot;color: #0000BB&quot;&gt;$selected &lt;/span&gt;&lt;span style=&quot;color: #007700&quot;&gt;= &lt;/span&gt;&lt;span style=&quot;color: #0000BB&quot;&gt;$argsList&lt;/span&gt;&lt;span style=&quot;color: #007700&quot;&gt;[&lt;/span&gt;&lt;span style=&quot;color: #0000BB&quot;&gt;0&lt;/span&gt;&lt;span style=&quot;color: #007700&quot;&gt;];&lt;br /&gt; for(&lt;/span&gt;&lt;span style=&quot;color: #0000BB&quot;&gt;$i&lt;/span&gt;&lt;span style=&quot;color: #007700&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color: #0000BB&quot;&gt;1&lt;/span&gt;&lt;span style=&quot;color: #007700&quot;&gt;;&lt;/span&gt;&lt;span style=&quot;color: #0000BB&quot;&gt;$argsCount&lt;/span&gt;&lt;span style=&quot;color: #007700&quot;&gt;;&lt;/span&gt;&lt;span style=&quot;color: #0000BB&quot;&gt;$i&lt;/span&gt;&lt;span style=&quot;color: #007700&quot;&gt;++)&lt;br /&gt; if( &lt;/span&gt;&lt;span style=&quot;color: #0000BB&quot;&gt;$argsCount&lt;/span&gt;&lt;span style=&quot;color: #007700&quot;&gt;%&lt;/span&gt;&lt;span style=&quot;color: #0000BB&quot;&gt;2&lt;/span&gt;&lt;span style=&quot;color: #007700&quot;&gt;==&lt;/span&gt;&lt;span style=&quot;color: #0000BB&quot;&gt;0 &lt;/span&gt;&lt;span style=&quot;color: #007700&quot;&gt;? &lt;br /&gt; &lt;/span&gt;&lt;span style=&quot;color: #0000BB&quot;&gt;$args&lt;/span&gt;&lt;span style=&quot;color: #007700&quot;&gt;[&lt;/span&gt;&lt;span style=&quot;color: #0000BB&quot;&gt;$i&lt;/span&gt;&lt;span style=&quot;color: #007700&quot;&gt;] &gt; &lt;/span&gt;&lt;span style=&quot;color: #0000BB&quot;&gt;$selected &lt;/span&gt;&lt;span style=&quot;color: #007700&quot;&gt;:&lt;br /&gt; &lt;/span&gt;&lt;span style=&quot;color: #0000BB&quot;&gt;$args&lt;/span&gt;&lt;span style=&quot;color: #007700&quot;&gt;[&lt;/span&gt;&lt;span style=&quot;color: #0000BB&quot;&gt;$i&lt;/span&gt;&lt;span style=&quot;color: #007700&quot;&gt;] &lt; &lt;/span&gt;&lt;span style=&quot;color: #0000BB&quot;&gt;$selected &lt;/span&gt;&lt;span style=&quot;color: #007700&quot;&gt;)&lt;br /&gt; &lt;/span&gt;&lt;span style=&quot;color: #0000BB&quot;&gt;$selected &lt;/span&gt;&lt;span style=&quot;color: #007700&quot;&gt;= &lt;/span&gt;&lt;span style=&quot;color: #0000BB&quot;&gt;$args&lt;/span&gt;&lt;span style=&quot;color: #007700&quot;&gt;[&lt;/span&gt;&lt;span style=&quot;color: #0000BB&quot;&gt;$i&lt;/span&gt;&lt;span style=&quot;color: #007700&quot;&gt;];&lt;br /&gt; return &lt;/span&gt;&lt;span style=&quot;color: #0000BB&quot;&gt;$selected&lt;/span&gt;&lt;span style=&quot;color: #007700&quot;&gt;;&lt;br /&gt;}&lt;br /&gt;&lt;/span&gt;&lt;span style=&quot;color: #0000BB&quot;&gt;?&gt;&lt;/span&gt;
&lt;/span&gt;
&lt;/code&gt;&lt;/p&gt; &lt;p&gt;On peut donc influencer le comportement d'une fonction &#224; travers son nombre d'argument.&lt;/p&gt; &lt;p&gt;Une autre m&#233;thode plus simple consiste &#224; positionner des arguments &#224; des valeurs par d&#233;faut dans le cas o&#249; ils ne sont pas sp&#233;cifi&#233;s.&lt;/p&gt; &lt;p&gt;&lt;strong&gt;Exemple de fonction &#224; argument par d&#233;faut&lt;/strong&gt;
Un exemple sur les pizzas.&lt;/p&gt; &lt;p&gt;&lt;code&gt;&lt;span style=&quot;color: #000000&quot;&gt;
&lt;span style=&quot;color: #0000BB&quot;&gt;&lt;?php&lt;br /&gt;&lt;br /&gt;$nb_pizza &lt;/span&gt;&lt;span style=&quot;color: #007700&quot;&gt;= &lt;/span&gt;&lt;span style=&quot;color: #0000BB&quot;&gt;0&lt;/span&gt;&lt;span style=&quot;color: #007700&quot;&gt;;&lt;br /&gt;&lt;br /&gt;function &lt;/span&gt;&lt;span style=&quot;color: #0000BB&quot;&gt;ajouter_pizza&lt;/span&gt;&lt;span style=&quot;color: #007700&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color: #0000BB&quot;&gt;$action &lt;/span&gt;&lt;span style=&quot;color: #007700&quot;&gt;= &lt;/span&gt;&lt;span style=&quot;color: #DD0000&quot;&gt;''&lt;/span&gt;&lt;span style=&quot;color: #007700&quot;&gt;,&lt;/span&gt;&lt;span style=&quot;color: #0000BB&quot;&gt;$nb &lt;/span&gt;&lt;span style=&quot;color: #007700&quot;&gt;= &lt;/span&gt;&lt;span style=&quot;color: #0000BB&quot;&gt;1&lt;/span&gt;&lt;span style=&quot;color: #007700&quot;&gt;){&lt;br /&gt; &lt;br /&gt; global &lt;/span&gt;&lt;span style=&quot;color: #0000BB&quot;&gt;$nb_pizza&lt;/span&gt;&lt;span style=&quot;color: #007700&quot;&gt;;&lt;br /&gt; &lt;br /&gt; switch(&lt;/span&gt;&lt;span style=&quot;color: #0000BB&quot;&gt;$action&lt;/span&gt;&lt;span style=&quot;color: #007700&quot;&gt;){&lt;br /&gt; &lt;br /&gt; case &lt;/span&gt;&lt;span style=&quot;color: #DD0000&quot;&gt;'affichage'&lt;/span&gt;&lt;span style=&quot;color: #007700&quot;&gt;:&lt;br /&gt; echo &lt;/span&gt;&lt;span style=&quot;color: #DD0000&quot;&gt;'Nombre de pizza actuel : '&lt;/span&gt;&lt;span style=&quot;color: #007700&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color: #0000BB&quot;&gt;$nb_pizza&lt;/span&gt;&lt;span style=&quot;color: #007700&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color: #DD0000&quot;&gt;'&lt;br&gt;'&lt;/span&gt;&lt;span style=&quot;color: #007700&quot;&gt;;&lt;br /&gt; break;&lt;br /&gt; &lt;br /&gt; case &lt;/span&gt;&lt;span style=&quot;color: #DD0000&quot;&gt;'envoyer'&lt;/span&gt;&lt;span style=&quot;color: #007700&quot;&gt;:&lt;br /&gt; &lt;/span&gt;&lt;span style=&quot;color: #0000BB&quot;&gt;$nb_pizza &lt;/span&gt;&lt;span style=&quot;color: #007700&quot;&gt;= &lt;/span&gt;&lt;span style=&quot;color: #0000BB&quot;&gt;$nb_pizza &lt;/span&gt;&lt;span style=&quot;color: #007700&quot;&gt;- &lt;/span&gt;&lt;span style=&quot;color: #0000BB&quot;&gt;$nb&lt;/span&gt;&lt;span style=&quot;color: #007700&quot;&gt;;&lt;br /&gt; echo &lt;/span&gt;&lt;span style=&quot;color: #DD0000&quot;&gt;'Il reste encore '&lt;/span&gt;&lt;span style=&quot;color: #007700&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color: #0000BB&quot;&gt;$nb_pizza&lt;/span&gt;&lt;span style=&quot;color: #007700&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color: #DD0000&quot;&gt;' pizza(s)&lt;br&gt;'&lt;/span&gt;&lt;span style=&quot;color: #007700&quot;&gt;;&lt;br /&gt; break;&lt;br /&gt; &lt;br /&gt; case &lt;/span&gt;&lt;span style=&quot;color: #DD0000&quot;&gt;''&lt;/span&gt;&lt;span style=&quot;color: #007700&quot;&gt;:&lt;br /&gt; &lt;/span&gt;&lt;span style=&quot;color: #0000BB&quot;&gt;$nb_pizza &lt;/span&gt;&lt;span style=&quot;color: #007700&quot;&gt;= &lt;/span&gt;&lt;span style=&quot;color: #0000BB&quot;&gt;$nb_pizza &lt;/span&gt;&lt;span style=&quot;color: #007700&quot;&gt;+ &lt;/span&gt;&lt;span style=&quot;color: #0000BB&quot;&gt;$nb&lt;/span&gt;&lt;span style=&quot;color: #007700&quot;&gt;;&lt;br /&gt; break;&lt;br /&gt; &lt;br /&gt; }&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;&lt;/span&gt;&lt;span style=&quot;color: #0000BB&quot;&gt;ajouter_pizza&lt;/span&gt;&lt;span style=&quot;color: #007700&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color: #DD0000&quot;&gt;''&lt;/span&gt;&lt;span style=&quot;color: #007700&quot;&gt;,&lt;/span&gt;&lt;span style=&quot;color: #0000BB&quot;&gt;3&lt;/span&gt;&lt;span style=&quot;color: #007700&quot;&gt;); &lt;/span&gt;&lt;span style=&quot;color: #FF8000&quot;&gt;// ajoute 3 pizza&lt;br /&gt;&lt;/span&gt;&lt;span style=&quot;color: #0000BB&quot;&gt;ajouter_pizza&lt;/span&gt;&lt;span style=&quot;color: #007700&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color: #DD0000&quot;&gt;'affichage'&lt;/span&gt;&lt;span style=&quot;color: #007700&quot;&gt;); &lt;/span&gt;&lt;span style=&quot;color: #FF8000&quot;&gt;// affiche les pizzas&lt;br /&gt;&lt;/span&gt;&lt;span style=&quot;color: #0000BB&quot;&gt;ajouter_pizza&lt;/span&gt;&lt;span style=&quot;color: #007700&quot;&gt;(); &lt;/span&gt;&lt;span style=&quot;color: #FF8000&quot;&gt;// ajoute 1 pizza ( valeur par d&#233;faut)&lt;br /&gt;&lt;/span&gt;&lt;span style=&quot;color: #0000BB&quot;&gt;ajouter_pizza&lt;/span&gt;&lt;span style=&quot;color: #007700&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color: #DD0000&quot;&gt;'affichage'&lt;/span&gt;&lt;span style=&quot;color: #007700&quot;&gt;); &lt;/span&gt;&lt;span style=&quot;color: #FF8000&quot;&gt;// affiche les pizzas&lt;br /&gt;&lt;/span&gt;&lt;span style=&quot;color: #0000BB&quot;&gt;ajouter_pizza&lt;/span&gt;&lt;span style=&quot;color: #007700&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color: #DD0000&quot;&gt;'envoyer'&lt;/span&gt;&lt;span style=&quot;color: #007700&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color: #0000BB&quot;&gt;2&lt;/span&gt;&lt;span style=&quot;color: #007700&quot;&gt;); &lt;/span&gt;&lt;span style=&quot;color: #FF8000&quot;&gt;// Enl&#232;ve 2 pizzas et affiche le nombre restant&lt;br /&gt;&lt;/span&gt;&lt;span style=&quot;color: #0000BB&quot;&gt;?&gt;&lt;/span&gt;
&lt;/span&gt;
&lt;/code&gt;&lt;/p&gt; &lt;p&gt;++++&lt;/p&gt; &lt;h3 class=&quot;spip&quot; id=&quot;outil_sommaire_1&quot;&gt;&lt;a title=&quot;Sommaire&quot; href=&quot;http://blog.6tech.net/spip.php?page=backend#outil_sommaire&quot; class=&quot;sommaire_ancre&quot;&gt; &lt;/a&gt; Appel de m&#233;thode d'objet &lt;/h3&gt;
&lt;p&gt;En Php5, on peut r&#233;cup&#233;rer les appels de m&#233;thodes et traiter les informations d'une fa&#231;on diff&#233;rente gr&#226;ce &#224; la m&#233;thode &lt;strong&gt;__call()&lt;/strong&gt; qui s'occupera de g&#233;rer les appels aux fonctions inexistantes.&lt;/p&gt; &lt;p&gt;&lt;strong&gt; Exemple avec __call()&lt;/strong&gt;&lt;/p&gt; &lt;p&gt;&lt;code&gt;&lt;span style=&quot;color: #000000&quot;&gt;
&lt;span style=&quot;color: #0000BB&quot;&gt;&lt;?php&lt;br /&gt;&lt;/span&gt;&lt;span style=&quot;color: #007700&quot;&gt;class &lt;/span&gt;&lt;span style=&quot;color: #0000BB&quot;&gt;Pizzeria &lt;/span&gt;&lt;span style=&quot;color: #007700&quot;&gt;{&lt;br /&gt;&lt;br /&gt; private &lt;/span&gt;&lt;span style=&quot;color: #0000BB&quot;&gt;$pizzaCounter &lt;/span&gt;&lt;span style=&quot;color: #007700&quot;&gt;= &lt;/span&gt;&lt;span style=&quot;color: #0000BB&quot;&gt;0&lt;/span&gt;&lt;span style=&quot;color: #007700&quot;&gt;;&lt;br /&gt; private &lt;/span&gt;&lt;span style=&quot;color: #0000BB&quot;&gt;$pizzaStorage &lt;/span&gt;&lt;span style=&quot;color: #007700&quot;&gt;= array();&lt;br /&gt;&lt;br /&gt; public function &lt;/span&gt;&lt;span style=&quot;color: #0000BB&quot;&gt;__call&lt;/span&gt;&lt;span style=&quot;color: #007700&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color: #0000BB&quot;&gt;$name&lt;/span&gt;&lt;span style=&quot;color: #007700&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color: #0000BB&quot;&gt;$args&lt;/span&gt;&lt;span style=&quot;color: #007700&quot;&gt;) {&lt;br /&gt; &lt;/span&gt;&lt;span style=&quot;color: #FF8000&quot;&gt;// Si la m&#233;thode appel&#233;e s'appelle 'modifyPizza'&lt;br /&gt; &lt;/span&gt;&lt;span style=&quot;color: #007700&quot;&gt;if( &lt;/span&gt;&lt;span style=&quot;color: #0000BB&quot;&gt;$name &lt;/span&gt;&lt;span style=&quot;color: #007700&quot;&gt;== &lt;/span&gt;&lt;span style=&quot;color: #DD0000&quot;&gt;'modifyPizza' &lt;/span&gt;&lt;span style=&quot;color: #007700&quot;&gt;){&lt;br /&gt; &lt;/span&gt;&lt;span style=&quot;color: #0000BB&quot;&gt;$argsCount &lt;/span&gt;&lt;span style=&quot;color: #007700&quot;&gt;= &lt;/span&gt;&lt;span style=&quot;color: #0000BB&quot;&gt;count&lt;/span&gt;&lt;span style=&quot;color: #007700&quot;&gt;( &lt;/span&gt;&lt;span style=&quot;color: #0000BB&quot;&gt;$args &lt;/span&gt;&lt;span style=&quot;color: #007700&quot;&gt;);&lt;br /&gt; &lt;/span&gt;&lt;span style=&quot;color: #FF8000&quot;&gt;// Si il y a un argument pass&#233; &#224; la fonction&lt;br /&gt; &lt;/span&gt;&lt;span style=&quot;color: #007700&quot;&gt;if( &lt;/span&gt;&lt;span style=&quot;color: #0000BB&quot;&gt;$argsCount &lt;/span&gt;&lt;span style=&quot;color: #007700&quot;&gt;== &lt;/span&gt;&lt;span style=&quot;color: #0000BB&quot;&gt;1 &lt;/span&gt;&lt;span style=&quot;color: #007700&quot;&gt;){&lt;br /&gt; &lt;/span&gt;&lt;span style=&quot;color: #FF8000&quot;&gt;// On va ajouter une pizza&lt;br /&gt; &lt;/span&gt;&lt;span style=&quot;color: #007700&quot;&gt;return &lt;/span&gt;&lt;span style=&quot;color: #0000BB&quot;&gt;call_user_func_array&lt;/span&gt;&lt;span style=&quot;color: #007700&quot;&gt;(array(&amp;&lt;/span&gt;&lt;span style=&quot;color: #0000BB&quot;&gt;$this&lt;/span&gt;&lt;span style=&quot;color: #007700&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color: #DD0000&quot;&gt;'addPizza'&lt;/span&gt;&lt;span style=&quot;color: #007700&quot;&gt;), &lt;/span&gt;&lt;span style=&quot;color: #0000BB&quot;&gt;$args&lt;/span&gt;&lt;span style=&quot;color: #007700&quot;&gt;);&lt;br /&gt; &lt;/span&gt;&lt;span style=&quot;color: #FF8000&quot;&gt;// Si il y'en a deux&lt;br /&gt; &lt;/span&gt;&lt;span style=&quot;color: #007700&quot;&gt;} else if( &lt;/span&gt;&lt;span style=&quot;color: #0000BB&quot;&gt;$argsCount &lt;/span&gt;&lt;span style=&quot;color: #007700&quot;&gt;== &lt;/span&gt;&lt;span style=&quot;color: #0000BB&quot;&gt;2 &lt;/span&gt;&lt;span style=&quot;color: #007700&quot;&gt;){&lt;br /&gt; &lt;/span&gt;&lt;span style=&quot;color: #FF8000&quot;&gt;// On va modifier le nom d'une pizza&lt;br /&gt; &lt;/span&gt;&lt;span style=&quot;color: #007700&quot;&gt;return &lt;/span&gt;&lt;span style=&quot;color: #0000BB&quot;&gt;call_user_func_array&lt;/span&gt;&lt;span style=&quot;color: #007700&quot;&gt;(array(&amp;&lt;/span&gt;&lt;span style=&quot;color: #0000BB&quot;&gt;$this&lt;/span&gt;&lt;span style=&quot;color: #007700&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color: #DD0000&quot;&gt;'modifyPizzaName'&lt;/span&gt;&lt;span style=&quot;color: #007700&quot;&gt;), &lt;/span&gt;&lt;span style=&quot;color: #0000BB&quot;&gt;$args&lt;/span&gt;&lt;span style=&quot;color: #007700&quot;&gt;);&lt;br /&gt; }&lt;br /&gt; }&lt;br /&gt; }&lt;br /&gt; &lt;br /&gt; public function &lt;/span&gt;&lt;span style=&quot;color: #0000BB&quot;&gt;addPizza&lt;/span&gt;&lt;span style=&quot;color: #007700&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color: #0000BB&quot;&gt;$name&lt;/span&gt;&lt;span style=&quot;color: #007700&quot;&gt;){&lt;br /&gt; &lt;/span&gt;&lt;span style=&quot;color: #0000BB&quot;&gt;$this &lt;/span&gt;&lt;span style=&quot;color: #007700&quot;&gt;-&gt; &lt;/span&gt;&lt;span style=&quot;color: #0000BB&quot;&gt;pizzaStorage&lt;/span&gt;&lt;span style=&quot;color: #007700&quot;&gt;[&lt;/span&gt;&lt;span style=&quot;color: #0000BB&quot;&gt;$name&lt;/span&gt;&lt;span style=&quot;color: #007700&quot;&gt;] = (int)&lt;/span&gt;&lt;span style=&quot;color: #0000BB&quot;&gt;$this &lt;/span&gt;&lt;span style=&quot;color: #007700&quot;&gt;-&gt; &lt;/span&gt;&lt;span style=&quot;color: #0000BB&quot;&gt;pizzaStorage&lt;/span&gt;&lt;span style=&quot;color: #007700&quot;&gt;[&lt;/span&gt;&lt;span style=&quot;color: #0000BB&quot;&gt;$name&lt;/span&gt;&lt;span style=&quot;color: #007700&quot;&gt;] + &lt;/span&gt;&lt;span style=&quot;color: #0000BB&quot;&gt;1&lt;/span&gt;&lt;span style=&quot;color: #007700&quot;&gt;;&lt;br /&gt; }&lt;br /&gt; &lt;br /&gt; public function &lt;/span&gt;&lt;span style=&quot;color: #0000BB&quot;&gt;modifyPizzaName&lt;/span&gt;&lt;span style=&quot;color: #007700&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color: #0000BB&quot;&gt;$oldName&lt;/span&gt;&lt;span style=&quot;color: #007700&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color: #0000BB&quot;&gt;$newName&lt;/span&gt;&lt;span style=&quot;color: #007700&quot;&gt;){&lt;br /&gt; &lt;/span&gt;&lt;span style=&quot;color: #FF8000&quot;&gt;// On r&#233;cup&#232;re le nombre de pizza anciennement nomm&#233;e oldName&lt;br /&gt; &lt;/span&gt;&lt;span style=&quot;color: #0000BB&quot;&gt;$pizzaStock &lt;/span&gt;&lt;span style=&quot;color: #007700&quot;&gt;= (int)&lt;/span&gt;&lt;span style=&quot;color: #0000BB&quot;&gt;$this &lt;/span&gt;&lt;span style=&quot;color: #007700&quot;&gt;-&gt; &lt;/span&gt;&lt;span style=&quot;color: #0000BB&quot;&gt;pizzaStorage&lt;/span&gt;&lt;span style=&quot;color: #007700&quot;&gt;[&lt;/span&gt;&lt;span style=&quot;color: #0000BB&quot;&gt;$oldName&lt;/span&gt;&lt;span style=&quot;color: #007700&quot;&gt;];&lt;br /&gt; &lt;/span&gt;&lt;span style=&quot;color: #FF8000&quot;&gt;// On supprime l'entr&#233;e correspondante&lt;br /&gt; &lt;/span&gt;&lt;span style=&quot;color: #007700&quot;&gt;unset(&lt;/span&gt;&lt;span style=&quot;color: #0000BB&quot;&gt;$this &lt;/span&gt;&lt;span style=&quot;color: #007700&quot;&gt;-&gt; &lt;/span&gt;&lt;span style=&quot;color: #0000BB&quot;&gt;pizzaStorage&lt;/span&gt;&lt;span style=&quot;color: #007700&quot;&gt;[&lt;/span&gt;&lt;span style=&quot;color: #0000BB&quot;&gt;$oldName&lt;/span&gt;&lt;span style=&quot;color: #007700&quot;&gt;]);&lt;br /&gt; &lt;/span&gt;&lt;span style=&quot;color: #FF8000&quot;&gt;// On cr&#233;&#233; la nouvelle entr&#233;e&lt;br /&gt; &lt;/span&gt;&lt;span style=&quot;color: #0000BB&quot;&gt;$this &lt;/span&gt;&lt;span style=&quot;color: #007700&quot;&gt;-&gt; &lt;/span&gt;&lt;span style=&quot;color: #0000BB&quot;&gt;pizzaStorage&lt;/span&gt;&lt;span style=&quot;color: #007700&quot;&gt;[&lt;/span&gt;&lt;span style=&quot;color: #0000BB&quot;&gt;$newName&lt;/span&gt;&lt;span style=&quot;color: #007700&quot;&gt;] = &lt;/span&gt;&lt;span style=&quot;color: #0000BB&quot;&gt;$pizzaStock&lt;/span&gt;&lt;span style=&quot;color: #007700&quot;&gt;;&lt;br /&gt; }&lt;br /&gt; &lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;&lt;/span&gt;&lt;span style=&quot;color: #0000BB&quot;&gt;$pizzeria &lt;/span&gt;&lt;span style=&quot;color: #007700&quot;&gt;= new &lt;/span&gt;&lt;span style=&quot;color: #0000BB&quot;&gt;Pizzeria&lt;/span&gt;&lt;span style=&quot;color: #007700&quot;&gt;();&lt;br /&gt;&lt;/span&gt;&lt;span style=&quot;color: #0000BB&quot;&gt;$pizzeria &lt;/span&gt;&lt;span style=&quot;color: #007700&quot;&gt;-&gt; &lt;/span&gt;&lt;span style=&quot;color: #0000BB&quot;&gt;modifyPizza&lt;/span&gt;&lt;span style=&quot;color: #007700&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color: #DD0000&quot;&gt;'Pizza aux 4 fromages'&lt;/span&gt;&lt;span style=&quot;color: #007700&quot;&gt;); &lt;/span&gt;&lt;span style=&quot;color: #FF8000&quot;&gt;// on cr&#233;&#233; un stock de 1 pour les &quot;Pizza aux 4 fromages&quot;&lt;br /&gt;&lt;/span&gt;&lt;span style=&quot;color: #0000BB&quot;&gt;$pizzeria &lt;/span&gt;&lt;span style=&quot;color: #007700&quot;&gt;-&gt; &lt;/span&gt;&lt;span style=&quot;color: #0000BB&quot;&gt;modifyPizza&lt;/span&gt;&lt;span style=&quot;color: #007700&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color: #DD0000&quot;&gt;'Pissaadi&#232;'&lt;/span&gt;&lt;span style=&quot;color: #007700&quot;&gt;); &lt;/span&gt;&lt;span style=&quot;color: #FF8000&quot;&gt;// on cr&#233;&#233; un stock de 1 pour les &quot;Pissaadi&#232;&quot;&lt;br /&gt;// Mais on a fait une faute on d&#233;cide de changer le nom&lt;br /&gt;&lt;/span&gt;&lt;span style=&quot;color: #0000BB&quot;&gt;$pizzeria &lt;/span&gt;&lt;span style=&quot;color: #007700&quot;&gt;-&gt; &lt;/span&gt;&lt;span style=&quot;color: #0000BB&quot;&gt;modifyPizza&lt;/span&gt;&lt;span style=&quot;color: #007700&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color: #DD0000&quot;&gt;'Pissaadi&#232;'&lt;/span&gt;&lt;span style=&quot;color: #007700&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color: #DD0000&quot;&gt;'Pissaladi&#232;re'&lt;/span&gt;&lt;span style=&quot;color: #007700&quot;&gt;); &lt;/span&gt;&lt;span style=&quot;color: #FF8000&quot;&gt;// on change le nom des &quot;Pissaadi&#232;&quot; en &quot;Pissaladi&#232;re&quot;&lt;br /&gt;&lt;/span&gt;&lt;span style=&quot;color: #0000BB&quot;&gt;?&gt;&lt;/span&gt;
&lt;/span&gt;
&lt;/code&gt;&lt;/p&gt; &lt;h3 class=&quot;spip&quot; id=&quot;outil_sommaire_2&quot;&gt;&lt;a title=&quot;Sommaire&quot; href=&quot;http://blog.6tech.net/spip.php?page=backend#outil_sommaire&quot; class=&quot;sommaire_ancre&quot;&gt; &lt;/a&gt; Surchage de getter et setter&lt;/h3&gt;
&lt;p&gt;De la m&#234;me mani&#232;re il est possible de surcharger les getters et setters d'une classe par la d&#233;finition des m&#233;thodes &lt;strong&gt;__get()&lt;/strong&gt; et &lt;strong&gt;__set()&lt;/strong&gt; qui vont automatiquement attraper les fonctions get**** et set**** si elles n'existent pas. Ensuite en jouant sur le nom de la fonction appel&#233;e ou le nombre d'argument, on peut facilement cr&#233;er des profile de fonction diff&#233;rent.&lt;/p&gt; &lt;p&gt;La surcharge de m&#233;thode prend un aspect diff&#233;rent des autres langages et s'affiche plus comme &#233;tant une liste de m&#233;thode de substitution et non de r&#233;el surcharge.&lt;/p&gt; &lt;h3 class=&quot;spip&quot; id=&quot;outil_sommaire_3&quot;&gt;&lt;a title=&quot;Sommaire&quot; href=&quot;http://blog.6tech.net/spip.php?page=backend#outil_sommaire&quot; class=&quot;sommaire_ancre&quot;&gt; &lt;/a&gt; Le gestionnaire d'erreur de PHP &lt;/h3&gt;
&lt;p&gt;Il est possible &#233;galement de red&#233;finir un gestionnaire en php et de r&#233;cup&#233;rer les erreurs li&#233;s &#224; un appel de fonction pour effectuer un autre traitement puis de continuer le reste de l'ex&#233;cution du script.&lt;/p&gt; &lt;p&gt;Ceci sera plus d&#233;taill&#233; dans un article sur les gestions d'erreurs en PHP&lt;/p&gt;&lt;/div&gt;
		
		</content:encoded>


		

	</item>



</channel>

</rss>

