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

<channel>
	<title>Antoine.Guiral.Info &#187; PHP</title>
	<atom:link href="http://antoine.guiral.info/category/php/feed/" rel="self" type="application/rss+xml" />
	<link>http://antoine.guiral.info</link>
	<description></description>
	<lastBuildDate>Mon, 15 Feb 2010 16:24:16 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.8.6</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>[facebook php] hiphop for php : une petite révolution dans le monde du développement web et de php</title>
		<link>http://antoine.guiral.info/2010/02/03/facebook-php-hiphop-for-php-une-petite-revolution-dans-le-monde-du-developpement-web-et-de-php/</link>
		<comments>http://antoine.guiral.info/2010/02/03/facebook-php-hiphop-for-php-une-petite-revolution-dans-le-monde-du-developpement-web-et-de-php/#comments</comments>
		<pubDate>Wed, 03 Feb 2010 04:59:45 +0000</pubDate>
		<dc:creator>Antoine</dc:creator>
				<category><![CDATA[PHP]]></category>
		<category><![CDATA[découverte]]></category>
		<category><![CDATA[facebook]]></category>
		<category><![CDATA[internet]]></category>
		<category><![CDATA[presentation]]></category>
		<category><![CDATA[Veille]]></category>

		<guid isPermaLink="false">http://antoine.guiral.info/?p=675</guid>
		<description><![CDATA[Facebook à annoncé hier la sortie en bêta de son dernier bébé : hip hop for php.  Cela fait deux ans que facebook travaille sur hip hop for php et les résultats encourageants de cet outil (en moyenne 50% d&#8217;utilisation processeur en moins suivant les pages) les ont conduits à proposer hip hop php sous ]]></description>
			<content:encoded><![CDATA[<p>Facebook à <a href="http://developers.facebook.com/news.php?blog=1&amp;story=358" target="_blank">annoncé hier</a> la sortie en bêta de son dernier bébé : hip hop for php.  Cela fait deux ans que facebook travaille sur hip hop for php et les résultats encourageants de cet outil (en moyenne 50% d&#8217;utilisation processeur en moins suivant les pages) les ont conduits à proposer hip hop php sous licence PHP. Autrement dit, tout le monde peut l&#8217;utiliser et accroitre ses performances!</p>
<h2>Hip Hop for php : c&#8217;est quoi?</h2>
<p>Hip hop n&#8217;est pas tout à fait un compilateur. C&#8217;est plutôt un transformateur de code qui va transformer votre PHP en C++. C&#8217;est ensuite ce C++ qui va être compilé avec g++ (gcc <img src='http://antoine.guiral.info/wp-includes/images/smilies/icon_wink.gif' alt=';)' class='wp-smiley' />  ). Il faut savoir que PHP est écrit en C et qu&#8217;il est possible de lui rajouter des extensions en C et C++. Ces extensions ont le mérite d&#8217;être ultra performante! Seul problème, ce n&#8217;est pas donné à tout le monde (savoir faire du PHP et du C++ et enfin créer des extensions à PHP en C++&#8230;). La solution fût donc de transformer le PHP en C++ puis de le compiler afin de bénéficer des avantages en termes de performances des langages compilés versus les langages interpretés.</p>
<h2>Hip Hop : ça marche comment?</h2>
<p>Le principe est plutôt simple. Sans que vous ne changiez rien à votre façon de coder, hiphop pour php va procéder à trois grande actions.</p>
<p>La première étape va être une analyse statique du code : qui appelle quoi, quelles sont les dépendances. Ensuite hiphop va trouver les meilleures correspondances de types de variables entre PHP (qui est un langage très peu typé) et C++ qui est fortement typé. Et enfin, hiphop va faire correspondre les expressions et déclarations PHP à leurs équivalentes en C++ (les deux langages dérivent du C).</p>
<p><a href="http://gcc.gnu.org/" target="_blank">G++</a> pourra alors faire son travail de compilation pour obtenir un code compilé et donc plus rapide.</p>
<div id="attachment_676" class="wp-caption aligncenter" style="width: 391px"><a href="http://antoine.guiral.info/wp-content/uploads/2010/02/HipHop_transformation_process.png"><img class="size-medium wp-image-676" title="HipHop_transformation_process" src="http://antoine.guiral.info/wp-content/uploads/2010/02/HipHop_transformation_process-300x187.png" alt="Processus de transfortmation du code par hiphop" width="381" height="237" /></a><p class="wp-caption-text">Processus de transfortmation du code par hiphop</p></div>
<p>Au niveau du processus de développement, un autre outil est mis à disposition : HPHPi. C&#8217;est un interprète qui va vous permettre de tester votre code sans pour autant le compiler. De cette manière vous ne changez rien à vos processus de développement.</p>
<h2>Résumé de la keynote de présentation de HipHop pour PHP</h2>
<p>J&#8217;ai regardé la keynote de présentation de Hiphop. Je vous propose un petit résumé. rien de transcendant (c&#8217;est pas une keynote apple quoi <img src='http://antoine.guiral.info/wp-includes/images/smilies/icon_biggrin.gif' alt=':D' class='wp-smiley' /> ) et la plus part des informations données était <a href="http://developers.facebook.com/news.php?blog=1&amp;story=358" target="_blank">dans ce billet</a>.</p>
<ul>
<li>PHP est un langage facile à apprendre et à mettre en place mais il fait parti avec PERL des langages &laquo;&nbsp;web&nbsp;&raquo; les plus consommateur de CPU</li>
<li>Vu la charge de Facebook (400 milliards de pages vues par mois) il était nécessaire de trouver une solution.
<ul>
<li>la réécriture de Facebook dans un langage plus performant? Pas possible sans stopper le développement de la plate forme (voir la roadmap&#8230;)</li>
<li>transformer toutes les parties du code qui ont une logique applicative complexe en extensions PHP écrites en C++ : très long à mettre en place et pas universel</li>
<li>La solution qui sera retenue : transformer le code PHP en C++ via HipHop fo PHP</li>
</ul>
</li>
<li>HipHop : né en 2007 et utilisé en production sur 90% du code de FaceBook depuis 6 mois:
<ul>
<li>pages web : 50% de consommation CPU en moisn a traffic équivalent (tests comprenant l&#8217;utilisation de memcache)</li>
<li>API : 30% d&#8217;utilisation CPU en moins pour un traffic deux fois supérieur</li>
</ul>
</li>
<li>Transformation du code avec HipHop :
<ul>
<li>effort sur les plus gros gains de performances que pouvait apporter l&#8217;utilisation de C++ :
<ul>
<li>appels de fonctions statiques</li>
<li>méthodes et propriétés statiques (OO)</li>
<li>chargement des variables statiques</li>
<li>g++ optimisation (function inline,&#8230;)</li>
</ul>
</li>
<li>Analyse statique : récupération de l&#8217;information &laquo;&nbsp;qui déclare quoi&nbsp;&raquo;</li>
<li>correspondance des types : meilleur type C++ correspondant à une variable PHP</li>
<li>code génération : pour la pluspart du code : correspondance directe entre les expressions PHP et C++ (if, else, for, while, etc etc)</li>
</ul>
</li>
<li>le runtime est similaire à Zend Engine mais plus rapide</li>
<li>Programmation avec HipHop :
<ul>
<li>support des fonctionnalités &laquo;&nbsp;magiques&nbsp;&raquo; de PHP :
<ul>
<li>appels dynamiques de fonctions (call_user_function(), &#8230;)</li>
<li>supprot des propriétés et méthodes dynamiques</li>
<li>variables dynamiques (avec extract() par exemple)</li>
<li>includes() dynamiques</li>
</ul>
</li>
<li>utilisation de l&#8217;interprète HPHPi pour tester le code sans le compiler</li>
</ul>
</li>
<li>En production : un processus multi-threadé, pas de downtime pendant les restarts, utilisable sur plusieurs serveurs</li>
<li>Roadmap : compatibilité avec php 5.3 (actuellement il marche avec php 5.2), Apache comme une option de serveur web, évoluer en fonction de l&#8217;usage en dehors de facebook (open source)</li>
<li>page du projet : <a href="http://developers.facebook.com/hiphop-php/" target="_blank">http://developers.facebook.com/hiphop-php/</a></li>
</ul>
<h2>HipHop : bien ou mal?</h2>
<p>J&#8217;ai un avis un peu partagé&#8230; Bien sûr que l&#8217;accroissement des performances sur une techno que j&#8217;utilise me plait bien <img src='http://antoine.guiral.info/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' />  Mais on pourrait voir une nouvelle tendance équivalente à &laquo;&nbsp;j&#8217;ai des gros serveurs donc je peux coder nimp&nbsp;&raquo; qui se traduirait par &laquo;&nbsp;j&#8217;utilise HipHop qui va compiler mon code donc pas la peine de l&#8217;optimiser&nbsp;&raquo;. D&#8217;un autre coté HipHop ne s&#8217;occupe que du PHP. On devrait donc aller vers une meilleur séparation du code (MVC inside). Donc je pense que le fossé va encore un peu plus grandir entre les master en PHP et les pseudo développeurs qui après une semaine sont &laquo;&nbsp;développeur web junior&nbsp;&raquo;. D&#8217;où mon partage d&#8217;opinion&#8230;grosse avancé techno mais techno un peu plusdifficile d&#8217;accés qu&#8217;avant (pourmoi ca me gêne pas mais bon plus ya de monde plus on rit :p ). <em>Et toi ? Qu&#8217;en penses tu?</em></p>
<p>Si le coeur t&#8217;en dit, voici la keynote :</p>
<p><object id="utv217539" classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" width="480" height="386" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,40,0"><param name="name" value="utv_n_240635" /><param name="flashvars" value="loc=%2F&amp;autoplay=false&amp;vid=4409735" /><param name="allowfullscreen" value="true" /><param name="allowscriptaccess" value="always" /><param name="src" value="http://www.ustream.tv/flash/video/4409735" /><embed id="utv217539" type="application/x-shockwave-flash" width="480" height="386" src="http://www.ustream.tv/flash/video/4409735" allowscriptaccess="always" allowfullscreen="true" flashvars="loc=%2F&amp;autoplay=false&amp;vid=4409735" name="utv_n_240635"></embed></object></p>
<ul class="related_post"><li><a href="http://antoine.guiral.info/2008/07/14/vu-sur-le-net-2-php-entrepreneuriat/" title="<!--:fr-->[vu sur le net] #2 dominante développement et entrepreneuriat<!--:-->"><!--:fr-->[vu sur le net] #2 dominante développement et entrepreneuriat<!--:--></a></li><li><a href="http://antoine.guiral.info/2008/04/19/presentation-de-jesuisnefr/" title="<!--:fr-->Présentation de jesuisné.fr<!--:-->"><!--:fr-->Présentation de jesuisné.fr<!--:--></a></li><li><a href="http://antoine.guiral.info/2008/01/19/tuto-mashup-galerie-photo-animee-via-flickr-recuperer-les-photos-12/" title="<!--:fr-->[tuto mashup] Galerie photo animée via Flickr : récupérer les photos (1/2)<!--:-->"><!--:fr-->[tuto mashup] Galerie photo animée via Flickr : récupérer les photos (1/2)<!--:--></a></li><li><a href="http://antoine.guiral.info/2008/01/18/vous-avez-dit-mashup/" title="<!--:fr-->Vous avez dit mashup?<!--:-->"><!--:fr-->Vous avez dit mashup?<!--:--></a></li><li><a href="http://antoine.guiral.info/2009/12/30/google-closure-hello-world-avec-closure-library/" title="<!--:fr-->[google closure] Hello world avec Closure Library<!--:-->"><!--:fr-->[google closure] Hello world avec Closure Library<!--:--></a></li><li><a href="http://antoine.guiral.info/2009/05/16/poo-php-mysql-lextension-objet-de-mysql-en-php-mysqli/" title="<!--:fr-->[poo php mysql] l&#8217;extension objet de mysql en php : mysqli<!--:-->"><!--:fr-->[poo php mysql] l&#8217;extension objet de mysql en php : mysqli<!--:--></a></li><li><a href="http://antoine.guiral.info/2009/05/07/poo-php-le-pattern-factory-1/" title="<!--:fr-->[poo php] le pattern factory #1<!--:-->"><!--:fr-->[poo php] le pattern factory #1<!--:--></a></li><li><a href="http://antoine.guiral.info/2008/07/05/vu-sur-le-net-1-resume/" title="<!--:fr-->[vu sur le net] #1 résumé<!--:-->"><!--:fr-->[vu sur le net] #1 résumé<!--:--></a></li><li><a href="http://antoine.guiral.info/2008/05/02/tuto-jquery-navigation-en-ajax-non-intrusif-22/" title="<!--:fr-->[tuto jQuery] navigation en ajax non-intrusif (2/2)<!--:-->"><!--:fr-->[tuto jQuery] navigation en ajax non-intrusif (2/2)<!--:--></a></li><li><a href="http://antoine.guiral.info/2008/04/20/tuto-jquery-navigation-en-ajax-non-intrusif-12/" title="<!--:fr-->[tuto jQuery] navigation en ajax non-intrusif (1/2)<!--:-->"><!--:fr-->[tuto jQuery] navigation en ajax non-intrusif (1/2)<!--:--></a></li></ul>]]></content:encoded>
			<wfw:commentRss>http://antoine.guiral.info/2010/02/03/facebook-php-hiphop-for-php-une-petite-revolution-dans-le-monde-du-developpement-web-et-de-php/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>[poo php mysql] l&#8217;extension objet de mysql en php : mysqli</title>
		<link>http://antoine.guiral.info/2009/05/16/poo-php-mysql-lextension-objet-de-mysql-en-php-mysqli/</link>
		<comments>http://antoine.guiral.info/2009/05/16/poo-php-mysql-lextension-objet-de-mysql-en-php-mysqli/#comments</comments>
		<pubDate>Sat, 16 May 2009 12:06:07 +0000</pubDate>
		<dc:creator>Antoine</dc:creator>
				<category><![CDATA[PHP]]></category>
		<category><![CDATA[découverte]]></category>
		<category><![CDATA[MySQL]]></category>
		<category><![CDATA[poo]]></category>

		<guid isPermaLink="false">http://antoine.guiral.info/?p=205</guid>
		<description><![CDATA[Après quelques péripéties avec ma machine (j&#8217;en reparlerai   ) voici enfin le tutoriel sur mysqli.
Alors mysqli kézako? Vous connaissez tous le SGBD MySQL, et son connecteur php mysql (et tout ses dérivés : mysql_connect, mysql_query, etc etc). Et bien mysqli n&#8217;est que le successeur de mysql. Dans les faits, PHP recommande d&#8217;utiliser mysqli ]]></description>
			<content:encoded><![CDATA[<p><!--:fr-->Après quelques péripéties avec ma machine (j&#8217;en reparlerai <img src='http://antoine.guiral.info/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' />  ) voici enfin le tutoriel sur mysqli.</p>
<p>Alors mysqli kézako? Vous connaissez tous le <a href="http://antoine.guiral.info/category/certification/mysql/">SGBD MySQL</a>, et son connecteur php mysql (et tout ses dérivés : mysql_connect, mysql_query, etc etc). Et bien mysqli n&#8217;est que le successeur de mysql. <!--:--><span id="more-205"></span><!--:fr-->Dans les faits, <a href="http://fr2.php.net/manual/fr/mysqli.overview.php" target="_blank">PHP recommande d&#8217;utiliser mysqli pour les versions de MySQL supérieures à 4.1.3</a>. Cependant beaucoup d&#8217;entre nous continuent à utiliser mysql.</p>
<p><!--:--><!--more--><!--:fr--></p>
<p>Mais pourquoi changer? Pour deux raisons. La première est que mysql ne prend pas en compte les dernières fonctionnalités de <a href="http://antoine.guiral.info/category/certification/mysql/">MySQL</a> et ceux depuis (je me répète) depuis la version 4.1.3! Pour information la version actuelle est 5.1.34 (stable)&#8230; La seconde raison, c&#8217;est que mysqli est un connecteur objet! Et c&#8217;est un excellent moyen d&#8217;appronfondir un peu plus nos connaissances de la <a title="la poo avec php5" href="http://antoine.guiral.info/tag/poo/" target="_blank">programmation orientée objet</a> avec php (php5 plus précisemment). Pour les plus réfractaires à la <a title="poo avec php5" href="http://antoine.guiral.info/tag/poo/" target="_blank">poo</a>, ils n&#8217;ont pas d&#8217;excuses! Mysqli est aussi utilisable en procédurale <img src='http://antoine.guiral.info/wp-includes/images/smilies/icon_biggrin.gif' alt=':D' class='wp-smiley' /> </p>
<p>Nous allons donc voir, dans la continuité du <a title="le design pattern factory en poo avec php5" href="http://antoine.guiral.info/2009/05/07/poo-php-le-pattern-factory-1/" target="_self">tutoriel sur les factory</a>, comment utiliser mysqli dans un contexte objet pour rester dans notre série sur la poo avc php. Pour un meilleur confort de lecture et pour que ce blog puisse continuer à tourner régulièrement je vous encourage à voir<a title="Merci :)" href="http://www.weecast.fr/php/mysqli,4309.html" target="_blank"> ce screencast sur weecast</a> :<br />
<object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" width="400" height="289" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,40,0"><param name="align" value="middle" /><param name="allowfullscreen" value="true" /><param name="allowscriptaccess" value="always" /><param name="src" value="http://www.weecast.fr/preview.swf?idfiche=4309" /><embed type="application/x-shockwave-flash" width="400" height="289" src="http://www.weecast.fr/preview.swf?idfiche=4309" allowscriptaccess="always" allowfullscreen="true" align="middle"></embed></object><br />
Retrouvez ce <a title="tutorial video Mysqli" href="http://www.weecast.fr/php/mysqli,4309.html">tutorial vidéo</a> sur  <a title="weecast achetez et vendez vos tutoriaux" href="http://www.weecast.fr/">Weecast</a>.</p>
<p>Sinon vous pouvez toujours le voir gratuitement sur vimeo <img src='http://antoine.guiral.info/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
<p><object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" width="400" height="300" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,40,0"><param name="allowfullscreen" value="true" /><param name="allowscriptaccess" value="always" /><param name="src" value="http://vimeo.com/moogaloop.swf?clip_id=4654628&amp;server=vimeo.com&amp;show_title=1&amp;show_byline=1&amp;show_portrait=0&amp;color=&amp;fullscreen=1" /><embed type="application/x-shockwave-flash" width="400" height="300" src="http://vimeo.com/moogaloop.swf?clip_id=4654628&amp;server=vimeo.com&amp;show_title=1&amp;show_byline=1&amp;show_portrait=0&amp;color=&amp;fullscreen=1" allowscriptaccess="always" allowfullscreen="true"></embed></object></p>
<p><a href="http://vimeo.com/4654628">Découvrir mysqli, le successeur du connecteur mysql pour php</a> from <a href="http://vimeo.com/user1255820">Antoine Guiral</a> on <a href="http://vimeo.com">Vimeo</a>.</p>
<p>Et PDO? PDO c&#8217;est la couche d&#8217;abstraction de base de donnée de php. Autrement dit vous faites vos requêtes pour PDO, puis selon votre configuration, PDO se charge des intéractions avec votre SGBD (SQLite, <a href="http://antoine.guiral.info/category/certification/mysql/">MySQL</a>, PostgreSQL, Oracle, Sybase, SQL Server, &#8230;). Donc un changement de base de données sera transparent pour votre application. Un bémol tout de même, à l&#8217;utilisation de PDO. Si PDO permet d&#8217;utiliser de la même manière tout els SGBD c&#8217;est donc qu&#8217;il ne prend pas en compte les spécificité de chaque SGBD. Et le choix de ce dernier se fait souvent sur ces petites différences! Donc personnellement je préfère exploiter à fond mon SGBD, quitte à perdre un peu d&#8217;évolutivité&#8230;au détriment des performances! C&#8217;est un choix discutable.</p>
<p>Et vous qu&#8217;utilisez vous? pourquoi?<!--:--></p>
<ul class="related_post"><li><a href="http://antoine.guiral.info/2009/05/07/poo-php-le-pattern-factory-1/" title="<!--:fr-->[poo php] le pattern factory #1<!--:-->"><!--:fr-->[poo php] le pattern factory #1<!--:--></a></li><li><a href="http://antoine.guiral.info/2008/01/19/tuto-mashup-galerie-photo-animee-via-flickr-recuperer-les-photos-12/" title="<!--:fr-->[tuto mashup] Galerie photo animée via Flickr : récupérer les photos (1/2)<!--:-->"><!--:fr-->[tuto mashup] Galerie photo animée via Flickr : récupérer les photos (1/2)<!--:--></a></li><li><a href="http://antoine.guiral.info/2010/02/03/facebook-php-hiphop-for-php-une-petite-revolution-dans-le-monde-du-developpement-web-et-de-php/" title="[facebook php] hiphop for php : une petite révolution dans le monde du développement web et de php">[facebook php] hiphop for php : une petite révolution dans le monde du développement web et de php</a></li><li><a href="http://antoine.guiral.info/2009/12/30/google-closure-hello-world-avec-closure-library/" title="<!--:fr-->[google closure] Hello world avec Closure Library<!--:-->"><!--:fr-->[google closure] Hello world avec Closure Library<!--:--></a></li><li><a href="http://antoine.guiral.info/2009/05/03/poo-php-notre-premiere-classe-en-action/" title="<!--:fr-->[poo php] notre première classe en action<!--:-->"><!--:fr-->[poo php] notre première classe en action<!--:--></a></li><li><a href="http://antoine.guiral.info/2009/01/28/poo-php-premiere-classe/" title="<!--:fr-->[poo php] première classe<!--:-->"><!--:fr-->[poo php] première classe<!--:--></a></li><li><a href="http://antoine.guiral.info/2009/01/28/poo-php-introduction/" title="<!--:fr-->[poo php] introduction<!--:-->"><!--:fr-->[poo php] introduction<!--:--></a></li><li><a href="http://antoine.guiral.info/2008/10/03/tuto-jquery-dragn-drop-avec-jquery-et-ajax-v2/" title="<!--:fr-->[tuto jquery] drag&#8217;n drop avec jquery et ajax V2<!--:-->"><!--:fr-->[tuto jquery] drag&#8217;n drop avec jquery et ajax V2<!--:--></a></li><li><a href="http://antoine.guiral.info/2008/01/24/tuto-mashup-google-maps-sur-votre-site-cest-possible-version-statique/" title="<!--:fr-->[tuto mashup] Google maps sur votre site : c&#8217;est possible! (version statique)<!--:-->"><!--:fr-->[tuto mashup] Google maps sur votre site : c&#8217;est possible! (version statique)<!--:--></a></li><li><a href="http://antoine.guiral.info/2008/01/17/annonce-prochain-tutoriel-flickrphpjquery-cest-pour-demain/" title="<!--:fr-->[annonce] Prochain tutoriel flickr/php/jquery : c&#8217;est pour demain!<!--:-->"><!--:fr-->[annonce] Prochain tutoriel flickr/php/jquery : c&#8217;est pour demain!<!--:--></a></li></ul>]]></content:encoded>
			<wfw:commentRss>http://antoine.guiral.info/2009/05/16/poo-php-mysql-lextension-objet-de-mysql-en-php-mysqli/feed/</wfw:commentRss>
		<slash:comments>5</slash:comments>
		</item>
		<item>
		<title>[poo php] le pattern factory #1</title>
		<link>http://antoine.guiral.info/2009/05/07/poo-php-le-pattern-factory-1/</link>
		<comments>http://antoine.guiral.info/2009/05/07/poo-php-le-pattern-factory-1/#comments</comments>
		<pubDate>Wed, 06 May 2009 22:27:20 +0000</pubDate>
		<dc:creator>Antoine</dc:creator>
				<category><![CDATA[PHP]]></category>
		<category><![CDATA[concept]]></category>
		<category><![CDATA[découverte]]></category>
		<category><![CDATA[poo]]></category>

		<guid isPermaLink="false">http://antoine.guiral.info/?p=202</guid>
		<description><![CDATA[Ce billet fait parti de la série sur la poo en php.
La dernière fois nous avions écrit notre première classe dans le cadre de notre apprentissage de la poo avec php. Un des problèmes que nous avions évoqué était qu&#8217;en php5 nous ne pouvions avoir qu&#8217;un constructeur (méthode __construct() ). C&#8217;est la raison &#171;&#160;pratique&#160;&#187; pour ]]></description>
			<content:encoded><![CDATA[<p><!--:fr-->Ce billet fait parti de<a href="http://antoine.guiral.info/2009/01/28/poo-php-introduction/"> la série</a> sur la poo en php.</p>
<p>La dernière fois<a title="Tutoriel Première classe en php" href="http://antoine.guiral.info/2009/01/28/poo-php-premiere-classe/"> nous avions écrit notre première classe </a>dans le cadre de notre apprentissage de la poo avec php. Un des problèmes que nous avions évoqué était qu&#8217;en php5 nous ne pouvions avoir qu&#8217;un constructeur (méthode __construct() ). C&#8217;est la raison &laquo;&nbsp;pratique&nbsp;&raquo; pour laquelle nous allons utiliser le pattern factory.<!--:--><span id="more-202"></span><!--:fr--></p>
<p>Cependant il y a d&#8217;autres raisons, que je classifie de &laquo;&nbsp;philosophiques&nbsp;&raquo;, au fait que nous utilisions les factories.</p>
<p>Mais tout d&#8217;abord <em>&laquo;&nbsp;c&#8217;est quoi un(e) factory??&nbsp;&raquo;</em></p>
<p><em><!--:--><!--more--><!--:fr--><br />
</em></p>
<p><span style="text-decoration: underline;">Le principe des factories</span></p>
<p>Techniquement c&#8217;est une classe qui ne contient que des méthodes statiques. Ces méthodes statiques retournent des objets. Par exemple, la classe UtilisateurFactory.class.php ne contiendra que des méthodes statiques qui retourneront des instances de Utilisateur.class.php. Les méthodes que nous pourrions retrouver sont :</p>
<ul>
<li>static function creerUtilisateur($login,$password,$mail);</li>
<li>static function loginUtilisateur($login,$password);</li>
</ul>
<p>Chaque méthode retournera un objet utilisateur. Ca c&#8217;était pour le coté technique. Regardons du coté &laquo;&nbsp;philosophique&nbsp;&raquo;.</p>
<p>Si il y a quelque chose sur lequel je porte de l&#8217;attention, c&#8217;est la clarté et la maintenabilité du code&#8230;autrement dit la &laquo;&nbsp;beauté&nbsp;&raquo; du code!</p>
<p>Et c&#8217;est la que les factories jouent doublement leur rôle. D&#8217;une part on sépare complètement la manière de créer un objet et l&#8217;objet en lui même. D&#8217;un côté les méthodes du factory servent juste à créer des objets (ce qui va correspondre en SQL à des INSERT/SELECT). De l&#8217;autre les méthodes de l&#8217;objet agissent <strong>DIRECTEMENT</strong> sur l&#8217;objet et correspondront à des UDPATE/DELETE en SQL.</p>
<p>Pour reprendre l&#8217;exemple de l&#8217;utilisateur : le factory se charge de créer l&#8217;utilisateur (INSERT) ou de le loggé (SELECT) et un utilisateur peux changer son mail (UPDATE) ou supprimer son compte (DELETE).</p>
<p>Ensuite, si on veut se rapprocher du model MVC, les factories simplifie enormement la lecture du code (et donc son écriture!) puisque au moment de la création seule la méthode correspondant à l&#8217;action à réaliser est appelée. Pas besoin de créer un objet, puis de &laquo;&nbsp;setter&nbsp;&raquo; les variables et ensuite d&#8217;appeler une méthode save, etc etc. Notre méthode creerUtilisateur se charge de tout.</p>
<p>Il y aurait encore beaucoup d&#8217;avantages à énumérer mais vous avez les principaux à mon sens <img src='http://antoine.guiral.info/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' />  C&#8217;est un peu déroutant au début et on est tout le temps en train de se demander &laquo;&nbsp;<em>alors ca ca va dans la factorie? dans laquelle? comment je l&#8217;appelle?</em>&nbsp;&raquo; mais après quelques heures on voit déjà les bénéfices <img src='http://antoine.guiral.info/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
<p>Dernier petit conseil, donnez des noms qui ont du sens à vos méthodes et variables. Ne pas hésiter par exemple à appeler une méthode : <em><strong>getBouteillesFromCasierByMillesimeAndAppellation</strong>($millesime,$appellation);</em> votre IDE se chargera de l&#8217;écrire à votre place les fois suivante <img src='http://antoine.guiral.info/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' />  Et personnelement je joue beaucoup sur les pluriels pour savoir si ma méthodes va me retourner un objet seul ou un tableau d&#8217;objets&#8230;</p>
<p>Pour mieux comprendre le sujet je vous propose de suivre ce screencast qui reprend les exemples précédents. Pour votre confort, activez la HD et le mode plein écran.</p>
<p><object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" width="400" height="300" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,40,0"><param name="allowfullscreen" value="true" /><param name="allowscriptaccess" value="always" /><param name="src" value="http://vimeo.com/moogaloop.swf?clip_id=4497191&amp;server=vimeo.com&amp;show_title=1&amp;show_byline=1&amp;show_portrait=0&amp;color=&amp;fullscreen=1" /><embed type="application/x-shockwave-flash" width="400" height="300" src="http://vimeo.com/moogaloop.swf?clip_id=4497191&amp;server=vimeo.com&amp;show_title=1&amp;show_byline=1&amp;show_portrait=0&amp;color=&amp;fullscreen=1" allowscriptaccess="always" allowfullscreen="true"></embed></object></p>
<p><a href="http://vimeo.com/4497191">[poo php] découverte du pattern factory</a> from <a href="http://vimeo.com/user1255820">Antoine Guiral</a> on <a href="http://vimeo.com">Vimeo</a>.<!--:--></p>
<ul class="related_post"><li><a href="http://antoine.guiral.info/2009/05/16/poo-php-mysql-lextension-objet-de-mysql-en-php-mysqli/" title="<!--:fr-->[poo php mysql] l&#8217;extension objet de mysql en php : mysqli<!--:-->"><!--:fr-->[poo php mysql] l&#8217;extension objet de mysql en php : mysqli<!--:--></a></li><li><a href="http://antoine.guiral.info/2009/05/03/poo-php-notre-premiere-classe-en-action/" title="<!--:fr-->[poo php] notre première classe en action<!--:-->"><!--:fr-->[poo php] notre première classe en action<!--:--></a></li><li><a href="http://antoine.guiral.info/2008/01/19/tuto-mashup-galerie-photo-animee-via-flickr-recuperer-les-photos-12/" title="<!--:fr-->[tuto mashup] Galerie photo animée via Flickr : récupérer les photos (1/2)<!--:-->"><!--:fr-->[tuto mashup] Galerie photo animée via Flickr : récupérer les photos (1/2)<!--:--></a></li><li><a href="http://antoine.guiral.info/2010/02/03/facebook-php-hiphop-for-php-une-petite-revolution-dans-le-monde-du-developpement-web-et-de-php/" title="[facebook php] hiphop for php : une petite révolution dans le monde du développement web et de php">[facebook php] hiphop for php : une petite révolution dans le monde du développement web et de php</a></li><li><a href="http://antoine.guiral.info/2009/12/30/google-closure-hello-world-avec-closure-library/" title="<!--:fr-->[google closure] Hello world avec Closure Library<!--:-->"><!--:fr-->[google closure] Hello world avec Closure Library<!--:--></a></li><li><a href="http://antoine.guiral.info/2009/05/02/accessibilite-faire-du-javascript-non-intrusif/" title="<!--:fr-->Accessibilité : Faire du javascript non-intrusif<!--:-->"><!--:fr-->Accessibilité : Faire du javascript non-intrusif<!--:--></a></li><li><a href="http://antoine.guiral.info/2009/01/28/poo-php-premiere-classe/" title="<!--:fr-->[poo php] première classe<!--:-->"><!--:fr-->[poo php] première classe<!--:--></a></li><li><a href="http://antoine.guiral.info/2009/01/28/poo-php-introduction/" title="<!--:fr-->[poo php] introduction<!--:-->"><!--:fr-->[poo php] introduction<!--:--></a></li><li><a href="http://antoine.guiral.info/2008/10/03/tuto-jquery-dragn-drop-avec-jquery-et-ajax-v2/" title="<!--:fr-->[tuto jquery] drag&#8217;n drop avec jquery et ajax V2<!--:-->"><!--:fr-->[tuto jquery] drag&#8217;n drop avec jquery et ajax V2<!--:--></a></li><li><a href="http://antoine.guiral.info/2008/05/02/tuto-jquery-navigation-en-ajax-non-intrusif-22/" title="<!--:fr-->[tuto jQuery] navigation en ajax non-intrusif (2/2)<!--:-->"><!--:fr-->[tuto jQuery] navigation en ajax non-intrusif (2/2)<!--:--></a></li></ul>]]></content:encoded>
			<wfw:commentRss>http://antoine.guiral.info/2009/05/07/poo-php-le-pattern-factory-1/feed/</wfw:commentRss>
		<slash:comments>14</slash:comments>
		</item>
		<item>
		<title>[poo php] notre première classe en action</title>
		<link>http://antoine.guiral.info/2009/05/03/poo-php-notre-premiere-classe-en-action/</link>
		<comments>http://antoine.guiral.info/2009/05/03/poo-php-notre-premiere-classe-en-action/#comments</comments>
		<pubDate>Sun, 03 May 2009 21:20:34 +0000</pubDate>
		<dc:creator>Antoine</dc:creator>
				<category><![CDATA[PHP]]></category>
		<category><![CDATA[concept]]></category>
		<category><![CDATA[poo]]></category>
		<category><![CDATA[tutoriel]]></category>

		<guid isPermaLink="false">http://antoine.guiral.info/?p=192</guid>
		<description><![CDATA[Ce billet fait parti de la série sur la poo en php5.
Dans l&#8217;article précédent nous avions vu les bases de la programmation objet (poo) en php. A savoir, la définition d&#8217;une classe, d&#8217;un objet, les attributs et méthodes et quelques méthodes spéciales (constructeurs,&#8230;). Autrement dit tout ce qui différencie la poo du procédural.
Aujourd&#8217;hui nous allons ]]></description>
			<content:encoded><![CDATA[<p><!--:fr-->Ce billet fait parti de<a href="http://antoine.guiral.info/2009/01/28/poo-php-introduction/"> la série</a> sur la poo en php5.</p>
<p>Dans <a title="premire classe en php5" href="http://antoine.guiral.info/2009/01/28/poo-php-premiere-classe/">l&#8217;article précédent</a> nous avions vu les bases de la programmation objet (poo) en php. A savoir, la définition d&#8217;une classe, d&#8217;un objet, les attributs et méthodes et quelques méthodes spéciales (constructeurs,&#8230;). Autrement dit tout ce qui différencie la poo du procédural.<!--:--><span id="more-192"></span><!--:fr--></p>
<p>Aujourd&#8217;hui nous allons aller un peu plus loin et mettre en pratique ce que nous avions appris. Je vous propose de prolonger <a title="Faire du javascript non intrusif avec jquery" href="http://antoine.guiral.info/2009/05/02/accessibilite-faire-du-javascript-non-intrusif/">l&#8217;article sur le javascript non intrusif</a> en complétant notre formulaire d&#8217;inscription afin d&#8217;en faire une entité qui fonctionne.</p>
<p><!--:--><!--more--><!--:fr--></p>
<p>Nous aurons donc une classe utilisateur avec comme attributs un id, un login, un mot de passe et un mail. Nous ajouterons une date d&#8217;inscription (cela nous permettra d&#8217;aborder un point particulier de mysql).</p>
<p>Dans ce screencast nous allons simplement créer notre classe avec netbeans. Pour votre confort je vous conseille de le visionner en HD (le texte est difficilement lisible sinon&#8230;).</p>
<p><object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" width="400" height="300" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,40,0"><param name="allowfullscreen" value="true" /><param name="allowscriptaccess" value="always" /><param name="src" value="http://vimeo.com/moogaloop.swf?clip_id=4460922&amp;server=vimeo.com&amp;show_title=1&amp;show_byline=1&amp;show_portrait=0&amp;color=&amp;fullscreen=1" /><embed type="application/x-shockwave-flash" width="400" height="300" src="http://vimeo.com/moogaloop.swf?clip_id=4460922&amp;server=vimeo.com&amp;show_title=1&amp;show_byline=1&amp;show_portrait=0&amp;color=&amp;fullscreen=1" allowscriptaccess="always" allowfullscreen="true"></embed></object></p>
<p><a href="http://vimeo.com/4460922">premiere classe en php5</a> from <a href="http://vimeo.com/user1255820">Antoine Guiral</a> on <a href="http://vimeo.com">Vimeo</a>.<!--:--></p>
<ul class="related_post"><li><a href="http://antoine.guiral.info/2009/05/07/poo-php-le-pattern-factory-1/" title="<!--:fr-->[poo php] le pattern factory #1<!--:-->"><!--:fr-->[poo php] le pattern factory #1<!--:--></a></li><li><a href="http://antoine.guiral.info/2009/05/02/accessibilite-faire-du-javascript-non-intrusif/" title="<!--:fr-->Accessibilité : Faire du javascript non-intrusif<!--:-->"><!--:fr-->Accessibilité : Faire du javascript non-intrusif<!--:--></a></li><li><a href="http://antoine.guiral.info/2008/10/03/tuto-jquery-dragn-drop-avec-jquery-et-ajax-v2/" title="<!--:fr-->[tuto jquery] drag&#8217;n drop avec jquery et ajax V2<!--:-->"><!--:fr-->[tuto jquery] drag&#8217;n drop avec jquery et ajax V2<!--:--></a></li><li><a href="http://antoine.guiral.info/2008/05/02/tuto-jquery-navigation-en-ajax-non-intrusif-22/" title="<!--:fr-->[tuto jQuery] navigation en ajax non-intrusif (2/2)<!--:-->"><!--:fr-->[tuto jQuery] navigation en ajax non-intrusif (2/2)<!--:--></a></li><li><a href="http://antoine.guiral.info/2008/04/20/tuto-jquery-navigation-en-ajax-non-intrusif-12/" title="<!--:fr-->[tuto jQuery] navigation en ajax non-intrusif (1/2)<!--:-->"><!--:fr-->[tuto jQuery] navigation en ajax non-intrusif (1/2)<!--:--></a></li><li><a href="http://antoine.guiral.info/2008/04/16/annonce-prochain-tutoriels-de-lajax-jquery-tuto/" title="<!--:fr-->[annonce] prochain tutoriels : de l&#8217;ajax avec jQuery<!--:-->"><!--:fr-->[annonce] prochain tutoriels : de l&#8217;ajax avec jQuery<!--:--></a></li><li><a href="http://antoine.guiral.info/2008/01/24/tuto-mashup-google-maps-sur-votre-site-cest-possible-version-statique/" title="<!--:fr-->[tuto mashup] Google maps sur votre site : c&#8217;est possible! (version statique)<!--:-->"><!--:fr-->[tuto mashup] Google maps sur votre site : c&#8217;est possible! (version statique)<!--:--></a></li><li><a href="http://antoine.guiral.info/2008/01/19/tuto-mashup-galerie-photo-animee-via-flickr-recuperer-les-photos-12/" title="<!--:fr-->[tuto mashup] Galerie photo animée via Flickr : récupérer les photos (1/2)<!--:-->"><!--:fr-->[tuto mashup] Galerie photo animée via Flickr : récupérer les photos (1/2)<!--:--></a></li><li><a href="http://antoine.guiral.info/2008/01/17/annonce-prochain-tutoriel-flickrphpjquery-cest-pour-demain/" title="<!--:fr-->[annonce] Prochain tutoriel flickr/php/jquery : c&#8217;est pour demain!<!--:-->"><!--:fr-->[annonce] Prochain tutoriel flickr/php/jquery : c&#8217;est pour demain!<!--:--></a></li><li><a href="http://antoine.guiral.info/2010/01/06/tuto-microformat-utiliser-le-microformat-hcalendar/" title="[tuto microformat] utiliser le microformat hCalendar">[tuto microformat] utiliser le microformat hCalendar</a></li></ul>]]></content:encoded>
			<wfw:commentRss>http://antoine.guiral.info/2009/05/03/poo-php-notre-premiere-classe-en-action/feed/</wfw:commentRss>
		<slash:comments>5</slash:comments>
		</item>
		<item>
		<title>[poo php] première classe</title>
		<link>http://antoine.guiral.info/2009/01/28/poo-php-premiere-classe/</link>
		<comments>http://antoine.guiral.info/2009/01/28/poo-php-premiere-classe/#comments</comments>
		<pubDate>Wed, 28 Jan 2009 18:26:57 +0000</pubDate>
		<dc:creator>Antoine</dc:creator>
				<category><![CDATA[PHP]]></category>
		<category><![CDATA[poo]]></category>

		<guid isPermaLink="false">http://antoine.guiral.info/?p=182</guid>
		<description><![CDATA[Ce billet fait parti de la série sur la poo en php5.
Dans un premier temps nous allons créer une classe qui ne sert pas à grand chose hormis de manipuler un peu tous les concepts de base de la programmation orienté objet (poo) en php.
Vous allez donc ouvrir votre IDE préféré (pour la poo j&#8217;utilise ]]></description>
			<content:encoded><![CDATA[<p><!--:fr-->Ce billet fait parti de<a href="http://antoine.guiral.info/2009/01/28/poo-php-introduction/"> la série</a> sur la poo en php5.</p>
<p>Dans un premier temps nous allons créer une classe qui ne sert pas à grand chose hormis de manipuler un peu tous les concepts de base de la programmation orienté objet (poo) en php.<!--:--><span id="more-182"></span><!--:fr--></p>
<p>Vous allez donc ouvrir votre IDE préféré (pour la poo j&#8217;utilise netbeans) et créer votre première classe. Personnellement je les appelle <em>MaClasse</em>.class.php (les noms de classe commencent par une majuscule) et les met toutes dans un dossier classes à la racine de mon projet.</p>
<p>Ensuite nous allons mettre deux lignes de codes pour indiquer à php que c&#8217;est une classe :</p>
<div class="geshi" style="overflow: auto; width: 560px;padding-bottom: 15px;clear:both;"><div class="php" style="color: #000066; border-left: 5px solid rgb(195, 215, 234); background-color: rgb(240, 240, 240); padding:1px;width:100%"><ol><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;font: normal normal 8pt 'Courier New', Courier, monospace; color: #003030;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div></li></ol></div></div>
<p>Voilà! Vous avez votre première classe! Bon ok elle est vide&#8230;Donc nous allons lui ajouter un attribut, un constructeur et une méthode qui va nous permettre de changer la valeur de son attribut.</p>
<div class="geshi" style="overflow: auto; width: 560px;padding-bottom: 15px;clear:both;"><div class="php" style="color: #000066; border-left: 5px solid rgb(195, 215, 234); background-color: rgb(240, 240, 240); padding:1px;width:100%"><ol><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;font: normal normal 8pt 'Courier New', Courier, monospace; color: #003030;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">monAttribut=<span style="color: #0000ff;">$initMonAttribut</span>;</div></li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;font: normal normal 8pt 'Courier New', Courier, monospace; color: #003030;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp;<span style="color: #66cc66;">&#125;</span></div></li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;font: normal normal 8pt 'Courier New', Courier, monospace; color: #003030;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div></li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;font: normal normal 8pt 'Courier New', Courier, monospace; color: #003030;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp;<span style="color: #000000; font-weight: bold;">function</span> setMonAttribut<span style="color: #66cc66;">&#40;</span><span style="color: #0000ff;">$valeur</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#123;</span></div></li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;font: normal normal 8pt 'Courier New', Courier, monospace; color: #003030;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; <span style="color: #0000ff;">$this</span>-&amp;gt;monAttribut=<span style="color: #0000ff;">$valeur</span>;</div></li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;font: normal normal 8pt 'Courier New', Courier, monospace; color: #003030;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp;<span style="color: #66cc66;">&#125;</span></div></li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;font: normal normal 8pt 'Courier New', Courier, monospace; color: #003030;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #66cc66;">&#125;</span></div></li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;font: normal normal 8pt 'Courier New', Courier, monospace; color: #003030;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">?&amp;gt;</div></li></ol></div></div>
<p><em>$this?? C&#8217;est quoi ce truc!</em> Pas de panique! La variable $this permet d&#8217;accéder aux attributs et méthodes à l&#8217;intérieur de l&#8217;objet. Maintenant nous allons tester notre classe <del datetime="2009-05-03T21:42:28+00:00">inutile</del>. Créez un fichier index.php et mettez y ce code :</p>
<div class="geshi" style="overflow: auto; width: 560px;padding-bottom: 15px;clear:both;"><div class="php" style="color: #000066; border-left: 5px solid rgb(195, 215, 234); background-color: rgb(240, 240, 240); padding:1px;width:100%"><ol><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;font: normal normal 8pt 'Courier New', Courier, monospace; color: #003030;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">monAttribut.PHP_EOL;</div></li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;font: normal normal 8pt 'Courier New', Courier, monospace; color: #003030;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp;<span style="color: #0000ff;">$monObjet</span>-&amp;gt;setMonAttribut<span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">'tiens je viens de changer de valeur'</span><span style="color: #66cc66;">&#41;</span>;</div></li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;font: normal normal 8pt 'Courier New', Courier, monospace; color: #003030;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp;<a href="http://www.php.net/echo"><span style="color: #000066;">echo</span></a> <span style="color: #0000ff;">$monObjet</span>-&amp;gt;monAttribut.PHP_EOL;</div></li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;font: normal normal 8pt 'Courier New', Courier, monospace; color: #003030;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp;<span style="color: #0000ff;">$monObjetVide</span>=<span style="color: #000000; font-weight: bold;">new</span> MaClasse<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>;</div></li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;font: normal normal 8pt 'Courier New', Courier, monospace; color: #003030;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp;<a href="http://www.php.net/echo"><span style="color: #000066;">echo</span></a> <span style="color: #0000ff;">$monObjetVide</span>-&amp;gt;monAttribut.PHP_EOL;</div></li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;font: normal normal 8pt 'Courier New', Courier, monospace; color: #003030;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">?&amp;gt;</div></li></ol></div></div>
<p>Comme vous pouvez le voir, pour instancier un objet on utilise le mot clé new suivi du nom de la classe. Ensuite pour accéder aux attributs ou aux méthodes on utilise la flèche (-&gt;).</p>
<p>Jusque là vous devriez avoir saisi les concepts évoqués, à savoir : comment créer une classe, comment déclarer un attribut et une méthode (dont la méthode magique __construct pour le constructeur) et comment accéder à ces dernier à l&#8217;intérieur de l&#8217;objet avec la variable $this.</p>
<p>Dans le prochain article <a href="http://antoine.guiral.info/2009/05/03/poo-php-notre-premiere-classe-en-action/">nous créerons notre première classe</a> utile. Vous commencerez alors à voir les bénéfices de la programmation orienté objet en php. C&#8217;est un peu déroutant au début surtout lorsque l&#8217;on a l&#8217;habitude de faire du procédural&#8230;<!--:--></p>
<ul class="related_post"><li><a href="http://antoine.guiral.info/2009/05/16/poo-php-mysql-lextension-objet-de-mysql-en-php-mysqli/" title="<!--:fr-->[poo php mysql] l&#8217;extension objet de mysql en php : mysqli<!--:-->"><!--:fr-->[poo php mysql] l&#8217;extension objet de mysql en php : mysqli<!--:--></a></li><li><a href="http://antoine.guiral.info/2009/05/07/poo-php-le-pattern-factory-1/" title="<!--:fr-->[poo php] le pattern factory #1<!--:-->"><!--:fr-->[poo php] le pattern factory #1<!--:--></a></li><li><a href="http://antoine.guiral.info/2009/05/03/poo-php-notre-premiere-classe-en-action/" title="<!--:fr-->[poo php] notre première classe en action<!--:-->"><!--:fr-->[poo php] notre première classe en action<!--:--></a></li><li><a href="http://antoine.guiral.info/2009/01/28/poo-php-introduction/" title="<!--:fr-->[poo php] introduction<!--:-->"><!--:fr-->[poo php] introduction<!--:--></a></li><li><a href="http://antoine.guiral.info/2008/01/24/tuto-mashup-google-maps-sur-votre-site-cest-possible-version-statique/" title="<!--:fr-->[tuto mashup] Google maps sur votre site : c&#8217;est possible! (version statique)<!--:-->"><!--:fr-->[tuto mashup] Google maps sur votre site : c&#8217;est possible! (version statique)<!--:--></a></li><li><a href="http://antoine.guiral.info/2008/01/19/tuto-mashup-galerie-photo-animee-via-flickr-recuperer-les-photos-12/" title="<!--:fr-->[tuto mashup] Galerie photo animée via Flickr : récupérer les photos (1/2)<!--:-->"><!--:fr-->[tuto mashup] Galerie photo animée via Flickr : récupérer les photos (1/2)<!--:--></a></li><li><a href="http://antoine.guiral.info/2008/01/17/annonce-prochain-tutoriel-flickrphpjquery-cest-pour-demain/" title="<!--:fr-->[annonce] Prochain tutoriel flickr/php/jquery : c&#8217;est pour demain!<!--:-->"><!--:fr-->[annonce] Prochain tutoriel flickr/php/jquery : c&#8217;est pour demain!<!--:--></a></li><li><a href="http://antoine.guiral.info/2010/02/03/facebook-php-hiphop-for-php-une-petite-revolution-dans-le-monde-du-developpement-web-et-de-php/" title="[facebook php] hiphop for php : une petite révolution dans le monde du développement web et de php">[facebook php] hiphop for php : une petite révolution dans le monde du développement web et de php</a></li><li><a href="http://antoine.guiral.info/2009/12/30/google-closure-hello-world-avec-closure-library/" title="<!--:fr-->[google closure] Hello world avec Closure Library<!--:-->"><!--:fr-->[google closure] Hello world avec Closure Library<!--:--></a></li><li><a href="http://antoine.guiral.info/2009/05/02/accessibilite-faire-du-javascript-non-intrusif/" title="<!--:fr-->Accessibilité : Faire du javascript non-intrusif<!--:-->"><!--:fr-->Accessibilité : Faire du javascript non-intrusif<!--:--></a></li></ul>]]></content:encoded>
			<wfw:commentRss>http://antoine.guiral.info/2009/01/28/poo-php-premiere-classe/feed/</wfw:commentRss>
		<slash:comments>10</slash:comments>
		</item>
		<item>
		<title>[poo php] introduction</title>
		<link>http://antoine.guiral.info/2009/01/28/poo-php-introduction/</link>
		<comments>http://antoine.guiral.info/2009/01/28/poo-php-introduction/#comments</comments>
		<pubDate>Wed, 28 Jan 2009 17:09:47 +0000</pubDate>
		<dc:creator>Antoine</dc:creator>
				<category><![CDATA[PHP]]></category>
		<category><![CDATA[poo]]></category>

		<guid isPermaLink="false">http://antoine.guiral.info/?p=178</guid>
		<description><![CDATA[Début d&#8217;une nouvelle série sur l&#8217;utilisation de la programmation orientée objet  (POO) et son implémentation avec php5.
Tout d&#8217;abord qu&#8217;est ce que c&#8217;est  que la POO.
C&#8217;est un concept de programmation qui s&#8217;oppose avec la  programmation procédurale. Classiquement nous programmons avec des fonctions et  des variables. Fonctions qui appellent d&#8217;autres fonctions, etc etc. ]]></description>
			<content:encoded><![CDATA[<p><!--:fr-->Début d&#8217;une nouvelle série sur l&#8217;utilisation de la programmation orientée objet  (POO) et son implémentation avec php5.</p>
<p>Tout d&#8217;abord qu&#8217;est ce que c&#8217;est  que la POO.</p>
<p>C&#8217;est un concept de programmation qui s&#8217;oppose avec la  programmation procédurale. Classiquement nous programmons avec des fonctions et  des variables. Fonctions qui appellent d&#8217;autres fonctions, etc etc. En C par  exemple on code de cette manière. Et malheureusement beaucoup trop en php  aussi.<!--:--><span id="more-178"></span><!--:fr--></p>
<p>Avec la POO au lieu de créer des fonctions à tout va vous  regroupez vos fonctions et variables en entités logiques. Par exemple si vous  voulez representer une voiture avant de lire ce tuto vous auriez (à la rigueur)  crée un fichier voiture.php puis aurez mis dedans toutes vos fonctions :  demarrer(), arreter(), passerVitesseSup(), retrograder(), etc et vos variables :  niveauCarburant, nbPortes, couleur, marque, modelé, etc. Et bien aujourd&#8217;hui  toutes ces fonctions et variables seront regroupées dans une entité logique.  Alors pour le moment vous ne voyez pas de différences&#8230;Donc avant d&#8217;aller plus  loin nous allons voir un peu de vocabulaire.</p>
<p>Notre entité logique  s&#8217;appelle une <strong>classe</strong>. C&#8217;est en quelques sortes un moule à objet. Autrement dit  nous avons une classe voiture qui va nous permettre de créer des objets  &laquo;&nbsp;voiture&nbsp;&raquo;. On dit alors qu&#8217;<strong>un objet est une instance d&#8217;une classe.</strong></p>
<p>Une  classe est composée de deux choses : <strong>des attributs et des méthodes.</strong> Les attributs  sont les variables de la classe, ici nous aurions : niveauCarburant, nbPortes,  couleur, etc&#8230; Tandis que les méthodes sont les fonctions de la classe. Dans  notre cas : demarrer(), arreter(),&#8230;</p>
<p>Une fois que nous avons notre  classe, nous voullons l&#8217;instancier pour obtenir des objets. Au moment de  l&#8217;instance le <strong>constructeur </strong>de la classe est appelé. Le constructeur est en fait  une méthode qui est automatiquement appelé lors de l&#8217;instance. En php5 elle  s&#8217;appelle toujours __construct(). Dans d&#8217;autre langages (java, php4,&#8230;) le  constructeur porte le même nom que la classe. Ce constructeur permet notamment  d&#8217;initialiser les attributs de l&#8217;objet. Ainsi nous pourrions avoir plusieurs  objets voitures ayant des attributs différents. Par exemple une opel astra avec  un reservoir vide et une renault safrane avec un reservoir plein. Ces deux  objets seront en fait deux instances différentes de la même classe.</p>
<p>Prochain billet : <a href="http://antoine.guiral.info/2009/01/28/poo-php-premiere-classe/">première classe</a>.<!--:--></p>
<ul class="related_post"><li><a href="http://antoine.guiral.info/2009/05/16/poo-php-mysql-lextension-objet-de-mysql-en-php-mysqli/" title="<!--:fr-->[poo php mysql] l&#8217;extension objet de mysql en php : mysqli<!--:-->"><!--:fr-->[poo php mysql] l&#8217;extension objet de mysql en php : mysqli<!--:--></a></li><li><a href="http://antoine.guiral.info/2009/05/07/poo-php-le-pattern-factory-1/" title="<!--:fr-->[poo php] le pattern factory #1<!--:-->"><!--:fr-->[poo php] le pattern factory #1<!--:--></a></li><li><a href="http://antoine.guiral.info/2009/05/03/poo-php-notre-premiere-classe-en-action/" title="<!--:fr-->[poo php] notre première classe en action<!--:-->"><!--:fr-->[poo php] notre première classe en action<!--:--></a></li><li><a href="http://antoine.guiral.info/2009/01/28/poo-php-premiere-classe/" title="<!--:fr-->[poo php] première classe<!--:-->"><!--:fr-->[poo php] première classe<!--:--></a></li><li><a href="http://antoine.guiral.info/2008/01/24/tuto-mashup-google-maps-sur-votre-site-cest-possible-version-statique/" title="<!--:fr-->[tuto mashup] Google maps sur votre site : c&#8217;est possible! (version statique)<!--:-->"><!--:fr-->[tuto mashup] Google maps sur votre site : c&#8217;est possible! (version statique)<!--:--></a></li><li><a href="http://antoine.guiral.info/2008/01/19/tuto-mashup-galerie-photo-animee-via-flickr-recuperer-les-photos-12/" title="<!--:fr-->[tuto mashup] Galerie photo animée via Flickr : récupérer les photos (1/2)<!--:-->"><!--:fr-->[tuto mashup] Galerie photo animée via Flickr : récupérer les photos (1/2)<!--:--></a></li><li><a href="http://antoine.guiral.info/2008/01/17/annonce-prochain-tutoriel-flickrphpjquery-cest-pour-demain/" title="<!--:fr-->[annonce] Prochain tutoriel flickr/php/jquery : c&#8217;est pour demain!<!--:-->"><!--:fr-->[annonce] Prochain tutoriel flickr/php/jquery : c&#8217;est pour demain!<!--:--></a></li><li><a href="http://antoine.guiral.info/2010/02/03/facebook-php-hiphop-for-php-une-petite-revolution-dans-le-monde-du-developpement-web-et-de-php/" title="[facebook php] hiphop for php : une petite révolution dans le monde du développement web et de php">[facebook php] hiphop for php : une petite révolution dans le monde du développement web et de php</a></li><li><a href="http://antoine.guiral.info/2009/12/30/google-closure-hello-world-avec-closure-library/" title="<!--:fr-->[google closure] Hello world avec Closure Library<!--:-->"><!--:fr-->[google closure] Hello world avec Closure Library<!--:--></a></li><li><a href="http://antoine.guiral.info/2009/05/02/accessibilite-faire-du-javascript-non-intrusif/" title="<!--:fr-->Accessibilité : Faire du javascript non-intrusif<!--:-->"><!--:fr-->Accessibilité : Faire du javascript non-intrusif<!--:--></a></li></ul>]]></content:encoded>
			<wfw:commentRss>http://antoine.guiral.info/2009/01/28/poo-php-introduction/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>[tuto php/sql] sécuriser ses requêtes SQL : sortez couvert!</title>
		<link>http://antoine.guiral.info/2008/03/28/tuto-php-sql-securiser-ses-requetes-sql-sortez-couvert/</link>
		<comments>http://antoine.guiral.info/2008/03/28/tuto-php-sql-securiser-ses-requetes-sql-sortez-couvert/#comments</comments>
		<pubDate>Fri, 28 Mar 2008 00:02:00 +0000</pubDate>
		<dc:creator>Antoine</dc:creator>
				<category><![CDATA[PHP]]></category>
		<category><![CDATA[concept]]></category>
		<category><![CDATA[sécurité]]></category>
		<category><![CDATA[sql]]></category>

		<guid isPermaLink="false">http://guiralantoine.wordpress.com/?p=67</guid>
		<description><![CDATA[Aujourd&#8217;hui rien de transcendant, mais plutôt quelque chose d&#8217;utile que j&#8217;utilise à chaque fois que je fais une requête vers une de mes bases de données. Je me protège des injections SQL.
J&#8217;utilise cette fonction pour chacune des variables que j&#8217;utilise dans mes requêtes.
function protection($string){
 if(get_magic_quotes_gpc()) {
 if(ini_get(&#8217;magic_quotes_sybase&#8217;)) {
 $string = str_replace(&#160;&#187;&#160;&#187;&#160;&#187;, &#171;&#160;&#8216;&#160;&#187;,$string);
 } else {
 ]]></description>
			<content:encoded><![CDATA[<p><!--:fr-->Aujourd&#8217;hui rien de transcendant, mais plutôt quelque chose d&#8217;utile que j&#8217;utilise à chaque fois que je fais une requête vers une de mes bases de données. Je me protège des <a href="http://fr.wikipedia.org/wiki/Injection_SQL" target="_blank">injections SQL</a>.</p>
<p>J&#8217;utilise cette fonction pour chacune des variables que j&#8217;utilise dans mes requêtes.</p>
<p><span style="color: #ff00ff;">function protection($string){</span></p>
<p><span style="color: #ff00ff;"> if(get_magic_quotes_gpc()) {</span></p>
<p><span style="color: #ff00ff;"> if(ini_get(&#8217;magic_quotes_sybase&#8217;)) {</span></p>
<p><span style="color: #ff00ff;"> $string = str_replace(&nbsp;&raquo;&nbsp;&raquo;&nbsp;&raquo;, &laquo;&nbsp;&#8216;&nbsp;&raquo;,$string);</span></p>
<p><span style="color: #ff00ff;"> } else {</span></p>
<p><span style="color: #ff00ff;"> $string = stripslashes($string);</span></p>
<p><span style="color: #ff00ff;"> }</span></p>
<p><span style="color: #ff00ff;"> }</span></p>
<p><span style="color: #ff00ff;"> return mysql_real_escape_string($string);</span></p>
<p><span style="color: #ff00ff;"> }</span></p>
<p>Pas grand chose à expliquer coté algo : on applique un traitement différent selon que les magic_quotes soient activées ou non sur votre serveur. Dans les deux cas vos variables seront protégées!</p>
<p>Pour l&#8217;utiliser rien de plus simple. Quand vous récupérez vos variables, vous les faites passer à la moulinette puis vous construisez votre requête <img src='http://antoine.guiral.info/wp-includes/images/smilies/icon_wink.gif' alt=';-)' class='wp-smiley' /> . Un petit exemple vaut mieux qu&#8217;un long discours :</p>
<pre>if(isset($_REQUEST['new_editeur'])){
            $editeur= protection($_REQUEST['new_editeur']);
            $sql='INSERT editeur VALUES(\'0\',\''.$editeur.'\')';
            $req=mysql_query($sql) or die('Erreur SQL !&lt;br&gt;'.$sql.'&lt;br&gt;'.mysql_error());
        }</pre>
<p>Avec ça vous allez pouvoir dormir sur vos deux oreilles!! Cependant je vous conseille de continuer à faire des sauvegardes TRÈS régulièrement de vos bases.<!--:--></p>
<ul class="related_post"><li><a href="http://antoine.guiral.info/2009/05/07/poo-php-le-pattern-factory-1/" title="<!--:fr-->[poo php] le pattern factory #1<!--:-->"><!--:fr-->[poo php] le pattern factory #1<!--:--></a></li><li><a href="http://antoine.guiral.info/2009/05/03/poo-php-notre-premiere-classe-en-action/" title="<!--:fr-->[poo php] notre première classe en action<!--:-->"><!--:fr-->[poo php] notre première classe en action<!--:--></a></li><li><a href="http://antoine.guiral.info/2009/05/02/accessibilite-faire-du-javascript-non-intrusif/" title="<!--:fr-->Accessibilité : Faire du javascript non-intrusif<!--:-->"><!--:fr-->Accessibilité : Faire du javascript non-intrusif<!--:--></a></li><li><a href="http://antoine.guiral.info/2008/10/03/tuto-jquery-dragn-drop-avec-jquery-et-ajax-v2/" title="<!--:fr-->[tuto jquery] drag&#8217;n drop avec jquery et ajax V2<!--:-->"><!--:fr-->[tuto jquery] drag&#8217;n drop avec jquery et ajax V2<!--:--></a></li><li><a href="http://antoine.guiral.info/2008/05/02/tuto-jquery-navigation-en-ajax-non-intrusif-22/" title="<!--:fr-->[tuto jQuery] navigation en ajax non-intrusif (2/2)<!--:-->"><!--:fr-->[tuto jQuery] navigation en ajax non-intrusif (2/2)<!--:--></a></li><li><a href="http://antoine.guiral.info/2008/04/20/tuto-jquery-navigation-en-ajax-non-intrusif-12/" title="<!--:fr-->[tuto jQuery] navigation en ajax non-intrusif (1/2)<!--:-->"><!--:fr-->[tuto jQuery] navigation en ajax non-intrusif (1/2)<!--:--></a></li><li><a href="http://antoine.guiral.info/2008/04/16/annonce-prochain-tutoriels-de-lajax-jquery-tuto/" title="<!--:fr-->[annonce] prochain tutoriels : de l&#8217;ajax avec jQuery<!--:-->"><!--:fr-->[annonce] prochain tutoriels : de l&#8217;ajax avec jQuery<!--:--></a></li><li><a href="http://antoine.guiral.info/2010/02/03/facebook-php-hiphop-for-php-une-petite-revolution-dans-le-monde-du-developpement-web-et-de-php/" title="[facebook php] hiphop for php : une petite révolution dans le monde du développement web et de php">[facebook php] hiphop for php : une petite révolution dans le monde du développement web et de php</a></li><li><a href="http://antoine.guiral.info/2010/01/28/apple-ipad-enorme-succes-de-lipad-a-la-derniere-keynote-dapple/" title="[apple iPad] énorme succés de l&#8217;iPad à la dernière keynote d&#8217;apple">[apple iPad] énorme succés de l&#8217;iPad à la dernière keynote d&#8217;apple</a></li><li><a href="http://antoine.guiral.info/2010/01/06/tuto-microformat-utiliser-le-microformat-hcalendar/" title="[tuto microformat] utiliser le microformat hCalendar">[tuto microformat] utiliser le microformat hCalendar</a></li></ul>]]></content:encoded>
			<wfw:commentRss>http://antoine.guiral.info/2008/03/28/tuto-php-sql-securiser-ses-requetes-sql-sortez-couvert/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>[tuto mashup] Google maps sur votre site : c&#8217;est possible! (version statique)</title>
		<link>http://antoine.guiral.info/2008/01/24/tuto-mashup-google-maps-sur-votre-site-cest-possible-version-statique/</link>
		<comments>http://antoine.guiral.info/2008/01/24/tuto-mashup-google-maps-sur-votre-site-cest-possible-version-statique/#comments</comments>
		<pubDate>Thu, 24 Jan 2008 19:47:36 +0000</pubDate>
		<dc:creator>Antoine</dc:creator>
				<category><![CDATA[PHP]]></category>
		<category><![CDATA[2.0]]></category>
		<category><![CDATA[api]]></category>
		<category><![CDATA[CSS]]></category>
		<category><![CDATA[google]]></category>
		<category><![CDATA[internet]]></category>
		<category><![CDATA[mashup]]></category>
		<category><![CDATA[poo]]></category>
		<category><![CDATA[tutoriel]]></category>
		<category><![CDATA[web]]></category>
		<category><![CDATA[xhtml]]></category>

		<guid isPermaLink="false">http://guiralantoine.wordpress.com/2008/01/24/tuto-mashup-google-maps-sur-votre-site-cest-possible-version-statique/</guid>
		<description><![CDATA[Je vous en parlais il y a quelque jours, le voila! Un petit tutoriel pour faire un mashup avec google maps sur votre site. J&#8217;ai réalisé un site début janvier pour l&#8217;école : www.le-passe-livre.com qui utilise google maps.

 Vue d&#8217;ensemble du tutoriel

Nous allons utiliser une classe php (une fois de plus  ) qui va ]]></description>
			<content:encoded><![CDATA[<p><!--:fr-->Je vous en parlais il y a quelque jours, le voila! Un petit tutoriel pour faire un <a title="Article sur les mashups" href="http://antoine.guiral.info/2008/01/18/vous-avez-dit-mashup/" target="_blank">mashup</a> avec <a title="Vous ne connaissez pas google maps?!" href="http://maps.google.com" target="_blank">google maps</a> sur votre site. J&#8217;ai réalisé un site début janvier pour l&#8217;école : <a title="Un petit site sorti de mon chapeau" href="http://www.le-passe-livre.com" target="_blank">www.le-passe-livre.com</a> qui utilise google maps.</p>
<ul>
<li> Vue d&#8217;ensemble du tutoriel</li>
</ul>
<p>Nous allons utiliser une classe php (une fois de plus <img src='http://antoine.guiral.info/wp-includes/images/smilies/icon_smile.gif' alt=':-)' class='wp-smiley' /> ) qui va nous permettre d&#8217;utiliser très simplement l&#8217;API de google. Comme presque toutes les API&#8217;s vous devez obtenir une clé pour pouvoir utiliser le service. Puis nous construirons notre google map en plaçant nos marqueurs sur la carte. Enfin nous l&#8217;afficherons.</p>
<ul>
<li>Télécharger la classe et activer l&#8217;API</li>
</ul>
<p>Vous pouvez <a href="http://www.e-caveavin.com/cv/tuto/google.rar">télécharger la classe ici</a>. Créez un dossier &laquo;&nbsp;classe&nbsp;&raquo; à la racine de votre site et décompressez l&#8217;archive à l&#8217;intérieur. Vous devez maintenant <a title="La clé c'est par là!" href="http://code.google.com/apis/maps/signup.html" target="_blank">obtenir la clé</a> qui va vous permettre d&#8217;utiliser l&#8217;API de google maps. Pour pouvoir tester votre site en local indiquez http://127.0.0.1/ pour l&#8217;url de votre site.</p>
<ul>
<li>Création de la carte google</li>
</ul>
<p>Je pense que le code est assez bien commenté. On créé une instance de notre carte, puis on fait le lien avec la clé google et on définit les caractéristiques de notre carte (taille,type de carte,etc etc).</p>
<div class="geshi" style="overflow: auto; width: 560px;padding-bottom: 15px;clear:both;"><div class="php" style="color: #000066; border-left: 5px solid rgb(195, 215, 234); background-color: rgb(240, 240, 240); padding:1px;width:100%"><ol><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;font: normal normal 8pt 'Courier New', Courier, monospace; color: #003030;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div></li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;font: normal normal 8pt 'Courier New', Courier, monospace; color: #003030;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #000000; font-weight: bold;">&lt;?php</span></div></li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;font: normal normal 8pt 'Courier New', Courier, monospace; color: #003030;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #b1b100;">require</span><span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">'includes/GoogleMapAPI.class.php'</span><span style="color: #66cc66;">&#41;</span>;</div></li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;font: normal normal 8pt 'Courier New', Courier, monospace; color: #003030;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #0000ff;">$map</span>-&gt;<span style="color: #006600;">setAPIKey</span><span style="color: #66cc66;">&#40;</span>’ABQIAAAAvjgjZ_Oh4DGvoa**************************EVoKaUlRpjBXuG0QTOhSYyitCXehqvZywz4H1mACoA3Y0nQ’<span style="color: #66cc66;">&#41;</span>;</div></li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;font: normal normal 8pt 'Courier New', Courier, monospace; color: #003030;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #808080; font-style: italic;">//quand je développe je met en comentaire la clé vers mon site //$map-&gt;setAPIKey(’ABQIAAAAvjgjZ_Oh4DGvoa**********************************KHDfvBQMU1YWoN3PfZpU2lJl5oJWX0pRyg’);</span></div></li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;font: normal normal 8pt 'Courier New', Courier, monospace; color: #003030;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #808080; font-style: italic;">//taille de la map</span></div></li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;font: normal normal 8pt 'Courier New', Courier, monospace; color: #003030;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #0000ff;">$map</span>-&gt;<span style="color: #006600;">setHeight</span><span style="color: #66cc66;">&#40;</span>”<span style="color: #cc66cc;">400</span>″<span style="color: #66cc66;">&#41;</span>;</div></li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;font: normal normal 8pt 'Courier New', Courier, monospace; color: #003030;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #0000ff;">$map</span>-&gt;<span style="color: #006600;">setWidth</span><span style="color: #66cc66;">&#40;</span>”<span style="color: #cc66cc;">600</span>″<span style="color: #66cc66;">&#41;</span>;</div></li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;font: normal normal 8pt 'Courier New', Courier, monospace; color: #003030;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #808080; font-style: italic;">//on desactive la barre de coté?</span></div></li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;font: normal normal 8pt 'Courier New', Courier, monospace; color: #003030;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #0000ff;">$map</span>-&gt;<span style="color: #006600;">disableSidebar</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>;</div></li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;font: normal normal 8pt 'Courier New', Courier, monospace; color: #003030;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #808080; font-style: italic;">//DesActive les boutons(map/satellite/hybrid).</span></div></li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;font: normal normal 8pt 'Courier New', Courier, monospace; color: #003030;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #0000ff;">$map</span>-&gt;<span style="color: #006600;">disableTypeControls</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>;</div></li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;font: normal normal 8pt 'Courier New', Courier, monospace; color: #003030;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #808080; font-style: italic;">//Quel est le type de carte par defaut ? (map/satellite/hybrid)</span></div></li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;font: normal normal 8pt 'Courier New', Courier, monospace; color: #003030;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #0000ff;">$map</span>-&gt;<span style="color: #006600;">setMapType</span><span style="color: #66cc66;">&#40;</span>’map’<span style="color: #66cc66;">&#41;</span>; <span style="color: #808080; font-style: italic;">// default</span></div></li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;font: normal normal 8pt 'Courier New', Courier, monospace; color: #003030;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #808080; font-style: italic;">//On déssactive les boutons pour afficher la direction d’un point a l’autre</span></div></li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;font: normal normal 8pt 'Courier New', Courier, monospace; color: #003030;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #0000ff;">$map</span>-&gt;<span style="color: #006600;">disableDirections</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>;</div></li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;font: normal normal 8pt 'Courier New', Courier, monospace; color: #003030;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #808080; font-style: italic;">// Permet de definir le zoom automatiquement afin de voir tous les marqueurs d’un coup.</span></div></li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;font: normal normal 8pt 'Courier New', Courier, monospace; color: #003030;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #0000ff;">$map</span>-&gt;<span style="color: #006600;">enableZoomEncompass</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>;</div></li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;font: normal normal 8pt 'Courier New', Courier, monospace; color: #003030;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #808080; font-style: italic;">//Active la mini map en bas a droite</span></div></li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;font: normal normal 8pt 'Courier New', Courier, monospace; color: #003030;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #0000ff;">$map</span>-&gt;<span style="color: #006600;">enableOverviewControl</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>;</div></li></ol></div></div>
<p>Notre carte est créée. Cependant elle est vide.</p>
<ul>
<li> Création d&#8217;un marqueur</li>
</ul>
<p>Il existe plusieurs façons de placer un marqueur. Soit par géolocalisation (en indiquant la longitude et la latitude), soit en indiquant l&#8217;adresse. Je vous présente uniquement la seconde méthode car il me semble que c&#8217;est la plus facile à mettre en œuvre. La méthode que nous utilisons, addMarkerByAdress, prend 3 arguments : l&#8217;adresse, le nom du marqueur, est le contenu que nous souhaitons afficher dans l&#8217;infobulle. Si vous souhaitez que votre infobulle comporte des onglets il faut passer un tableau en paramètre.</p>
<div class="geshi" style="overflow: auto; width: 560px; height: 300px; padding-bottom: 15px;clear:both"><div class="php" style="color: #000066; border-left: 5px solid rgb(195, 215, 234); background-color: rgb(240, 240, 240); padding:1px;width:100%"><ol><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;font: normal normal 8pt 'Courier New', Courier, monospace; color: #003030;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #808080; font-style: italic;">//Mon chez moi :p</span></div></li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;font: normal normal 8pt 'Courier New', Courier, monospace; color: #003030;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #0000ff;">$map</span>-&gt;<span style="color: #006600;">addMarkerByAddress</span><span style="color: #66cc66;">&#40;</span>’<span style="color: #cc66cc;">16</span> rue du <span style="color: #cc66cc;">71</span>ème mobile, <span style="color: #cc66cc;">87000</span> Limoges’,</div></li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;font: normal normal 8pt 'Courier New', Courier, monospace; color: #003030;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div></li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;font: normal normal 8pt 'Courier New', Courier, monospace; color: #003030;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">‘Chez moi’,</div></li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;font: normal normal 8pt 'Courier New', Courier, monospace; color: #003030;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div></li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;font: normal normal 8pt 'Courier New', Courier, monospace; color: #003030;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><a href="http://www.php.net/array"><span style="color: #000066;">array</span></a><span style="color: #66cc66;">&#40;</span></div></li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;font: normal normal 8pt 'Courier New', Courier, monospace; color: #003030;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div></li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;font: normal normal 8pt 'Courier New', Courier, monospace; color: #003030;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">‘Adresse’=&gt;’</div></li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;font: normal normal 8pt 'Courier New', Courier, monospace; color: #003030;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div></li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;font: normal normal 8pt 'Courier New', Courier, monospace; color: #003030;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #cc66cc;">16</span>, rue du <span style="color: #cc66cc;">71</span>ème mobile</div></li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;font: normal normal 8pt 'Courier New', Courier, monospace; color: #003030;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div></li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;font: normal normal 8pt 'Courier New', Courier, monospace; color: #003030;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">’,</div></li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;font: normal normal 8pt 'Courier New', Courier, monospace; color: #003030;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div></li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;font: normal normal 8pt 'Courier New', Courier, monospace; color: #003030;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">‘La ville’=&gt;’</div></li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;font: normal normal 8pt 'Courier New', Courier, monospace; color: #003030;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&lt;h1&gt;Limoges&lt;/h1&gt;</div></li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;font: normal normal 8pt 'Courier New', Courier, monospace; color: #003030;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div></li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;font: normal normal 8pt 'Courier New', Courier, monospace; color: #003030;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">C’est une ville agréable et relativement dynamique</div></li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;font: normal normal 8pt 'Courier New', Courier, monospace; color: #003030;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div></li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;font: normal normal 8pt 'Courier New', Courier, monospace; color: #003030;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">’,</div></li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;font: normal normal 8pt 'Courier New', Courier, monospace; color: #003030;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div></li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;font: normal normal 8pt 'Courier New', Courier, monospace; color: #003030;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">‘<span style="color: #cc66cc;">1</span>ère année’=&gt;’</div></li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;font: normal normal 8pt 'Courier New', Courier, monospace; color: #003030;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&lt;ul&gt;</div></li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;font: normal normal 8pt 'Courier New', Courier, monospace; color: #003030;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&lt;li&gt;Web : HTML, XHTML, CSS, AJAX, PHP, SQL.&lt;/li&gt;</div></li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;font: normal normal 8pt 'Courier New', Courier, monospace; color: #003030;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&lt;li&gt;Analyse : Bases de la méthode Merise.&lt;/li&gt;</div></li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;font: normal normal 8pt 'Courier New', Courier, monospace; color: #003030;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&lt;li&gt;C : Suivis du cursus de <span style="color: #cc66cc;">1</span>ère année à &lt;a href=<span style="color: #ff0000;">&quot;”www.3il.fr”&quot;</span>&gt;3il&lt;/a&gt;.&lt;/li&gt;</div></li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;font: normal normal 8pt 'Courier New', Courier, monospace; color: #003030;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&lt;li&gt;Environnement de travail : Eclipse, Linux, Windows.&lt;/li&gt;</div></li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;font: normal normal 8pt 'Courier New', Courier, monospace; color: #003030;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&lt;li&gt;Anglais : Niveau scolaire.&lt;/li&gt;</div></li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;font: normal normal 8pt 'Courier New', Courier, monospace; color: #003030;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&lt;/ul&gt;</div></li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;font: normal normal 8pt 'Courier New', Courier, monospace; color: #003030;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div></li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;font: normal normal 8pt 'Courier New', Courier, monospace; color: #003030;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">’,</div></li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;font: normal normal 8pt 'Courier New', Courier, monospace; color: #003030;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div></li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;font: normal normal 8pt 'Courier New', Courier, monospace; color: #003030;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">‘Extra’=&gt;’</div></li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;font: normal normal 8pt 'Courier New', Courier, monospace; color: #003030;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&lt;ul&gt;</div></li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;font: normal normal 8pt 'Courier New', Courier, monospace; color: #003030;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&lt;li&gt;Capitaine des espoirs de l’USAL&lt;/li&gt;</div></li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;font: normal normal 8pt 'Courier New', Courier, monospace; color: #003030;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&lt;li&gt;&lt;a href=<span style="color: #ff0000;">&quot;”http://newsussel.free.fr”&quot;</span> target=<span style="color: #ff0000;">&quot;”_blank”&quot;</span>&gt;Premier site internet&lt;/a&gt;&lt;/li&gt;</div></li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;font: normal normal 8pt 'Courier New', Courier, monospace; color: #003030;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&lt;/ul&gt;</div></li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;font: normal normal 8pt 'Courier New', Courier, monospace; color: #003030;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div></li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;font: normal normal 8pt 'Courier New', Courier, monospace; color: #003030;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">’<span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span>;</div></li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;font: normal normal 8pt 'Courier New', Courier, monospace; color: #003030;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div></li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;font: normal normal 8pt 'Courier New', Courier, monospace; color: #003030;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #000000; font-weight: bold;">?&gt;</span></div></li></ol></div></div>
<p>Comme vous pouvez le voir, les onglets peuvent contenir du code XHTML (et donc être mis en forme grâce aux CSS). Il ne reste plus qu&#8217;à afficher votre carte!</p>
<ul>
<li>Afficher la google map</li>
</ul>
<p>Petite explication préalable : la <strong>classe </strong>permet de nous <strong>simplifier </strong>la tâche en créant  le <strong>javascript </strong>à notre place. Nous avons donc les appels du javascript à générer dans notre &laquo;&nbsp;<strong>head</strong>&nbsp;&raquo; <strong>XHTML</strong>. De plus le javascript doit être exécuter une fois la page chargée. Nous appellerons donc une fonction sur l&#8217;événement <strong>onload </strong>de la balise <strong>body. </strong>Notre page sera fin prête à être affichée.</p>
<div class="geshi" style="overflow: auto; width: 560px;padding-bottom: 15px;clear:both;"><div class="php" style="color: #000066; border-left: 5px solid rgb(195, 215, 234); background-color: rgb(240, 240, 240); padding:1px;width:100%"><ol><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;font: normal normal 8pt 'Courier New', Courier, monospace; color: #003030;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div></li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;font: normal normal 8pt 'Courier New', Courier, monospace; color: #003030;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&lt;!DOCTYPE html <span style="color: #000000; font-weight: bold;">PUBLIC</span> <span style="color: #ff0000;">&quot;-//W3C//DTD XHTML 1.0 Strict//EN&quot;</span> <span style="color: #ff0000;">&quot;http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd&quot;</span>&gt;</div></li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;font: normal normal 8pt 'Courier New', Courier, monospace; color: #003030;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&lt;html xmlns=<span style="color: #ff0000;">&quot;http://www.w3.org/1999/xhtml&quot;</span> xmlns:v=<span style="color: #ff0000;">&quot;urn:schemas-microsoft-com:vml&quot;</span>&gt;</div></li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;font: normal normal 8pt 'Courier New', Courier, monospace; color: #003030;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&lt;head&gt;</div></li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;font: normal normal 8pt 'Courier New', Courier, monospace; color: #003030;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #808080; font-style: italic;">//nos fonctions javascript sont généres ici</span></div></li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;font: normal normal 8pt 'Courier New', Courier, monospace; color: #003030;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">&lt;?php</span> <span style="color: #0000ff;">$map</span>-&gt;<span style="color: #006600;">printHeaderJS</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>; <span style="color: #000000; font-weight: bold;">?&gt;</span></div></li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;font: normal normal 8pt 'Courier New', Courier, monospace; color: #003030;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">&lt;?php</span> <span style="color: #0000ff;">$map</span>-&gt;<span style="color: #006600;">printMapJS</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>; <span style="color: #000000; font-weight: bold;">?&gt;</span></div></li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;font: normal normal 8pt 'Courier New', Courier, monospace; color: #003030;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&lt;link rel=<span style="color: #ff0000;">&quot;stylesheet&quot;</span> type=<span style="color: #ff0000;">&quot;text/css&quot;</span> href=<span style="color: #ff0000;">&quot;styles.css&quot;</span> media=<span style="color: #ff0000;">&quot;all&quot;</span>/&gt;</div></li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;font: normal normal 8pt 'Courier New', Courier, monospace; color: #003030;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&lt;/head&gt;</div></li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;font: normal normal 8pt 'Courier New', Courier, monospace; color: #003030;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div></li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;font: normal normal 8pt 'Courier New', Courier, monospace; color: #003030;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&lt;body onload=<span style="color: #ff0000;">&quot;onLoad()&quot;</span>&gt;</div></li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;font: normal normal 8pt 'Courier New', Courier, monospace; color: #003030;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&lt;div id=<span style="color: #ff0000;">&quot;”map_map”&quot;</span>&gt;</div></li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;font: normal normal 8pt 'Courier New', Courier, monospace; color: #003030;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #808080; font-style: italic;">//la carte</span></div></li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;font: normal normal 8pt 'Courier New', Courier, monospace; color: #003030;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #000000; font-weight: bold;">&lt;?php</span> printMap<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>; <span style="color: #000000; font-weight: bold;">?&gt;</span></div></li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;font: normal normal 8pt 'Courier New', Courier, monospace; color: #003030;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #808080; font-style: italic;">//les raccourcis vers les marqueurs (2eme paramètre des marqueurs)</span></div></li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;font: normal normal 8pt 'Courier New', Courier, monospace; color: #003030;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #000000; font-weight: bold;">&lt;?php</span> printSidebar<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>;?&gt;&lt;/div&gt;</div></li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;font: normal normal 8pt 'Courier New', Courier, monospace; color: #003030;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div></li></ol></div></div>
<p>Il ne nous manque plus que les styles à créer.</p>
<ul>
<li>Les styles CSS</li>
</ul>
<p>Créez un dossier &laquo;&nbsp;<em>styles</em>&nbsp;&raquo; à la racine de votre site puis rajoutez y un fichier styles.css.</p>
<div class="geshi" style="overflow: auto; width: 560px;padding-bottom: 15px;clear:both;"><div class="css" style="color: #000066; border-left: 5px solid rgb(195, 215, 234); background-color: rgb(240, 240, 240); padding:1px;width:100%"><ol><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;font: normal normal 8pt 'Courier New', Courier, monospace; color: #003030;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #808080; font-style: italic;">/******gmap**************/</span></div></li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;font: normal normal 8pt 'Courier New', Courier, monospace; color: #003030;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div></li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;font: normal normal 8pt 'Courier New', Courier, monospace; color: #003030;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #808080; font-style: italic;">/* parait indispensable*/</span></div></li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;font: normal normal 8pt 'Courier New', Courier, monospace; color: #003030;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">v\:* <span style="color: #66cc66;">&#123;</span></div></li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;font: normal normal 8pt 'Courier New', Courier, monospace; color: #003030;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">behavior<span style="color: #3333ff;">:url</span><span style="color: #66cc66;">&#40;</span><span style="color: #cc00cc;">#default</span><span style="color: #cc00cc;">#VML</span><span style="color: #66cc66;">&#41;</span>;</div></li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;font: normal normal 8pt 'Courier New', Courier, monospace; color: #003030;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #66cc66;">&#125;</span></div></li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;font: normal normal 8pt 'Courier New', Courier, monospace; color: #003030;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div></li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;font: normal normal 8pt 'Courier New', Courier, monospace; color: #003030;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #808080; font-style: italic;">/*pour les infobulles de la carte*/</span></div></li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;font: normal normal 8pt 'Courier New', Courier, monospace; color: #003030;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #cc00cc;">#gmapmarker</span> <span style="color: #66cc66;">&#123;</span></div></li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;font: normal normal 8pt 'Courier New', Courier, monospace; color: #003030;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #000000; font-weight: bold;">font</span>: <span style="color: #993333;">normal</span> small verdana, arial, helvetica, <span style="color: #993333;">sans-serif</span>;</div></li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;font: normal normal 8pt 'Courier New', Courier, monospace; color: #003030;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #000000; font-weight: bold;">font-size</span>: <span style="color: #933;">10pt</span>;</div></li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;font: normal normal 8pt 'Courier New', Courier, monospace; color: #003030;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #000000; font-weight: bold;">margin</span>: <span style="color: #933;">0px</span>;</div></li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;font: normal normal 8pt 'Courier New', Courier, monospace; color: #003030;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #000000; font-weight: bold;">width</span>: <span style="color: #933;">250px</span>;</div></li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;font: normal normal 8pt 'Courier New', Courier, monospace; color: #003030;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #000000; font-weight: bold;">height</span>: <span style="color: #933;">100px</span>;</div></li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;font: normal normal 8pt 'Courier New', Courier, monospace; color: #003030;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">overflow<span style="color: #3333ff;">:auto</span>;</div></li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;font: normal normal 8pt 'Courier New', Courier, monospace; color: #003030;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #66cc66;">&#125;</span></div></li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;font: normal normal 8pt 'Courier New', Courier, monospace; color: #003030;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div></li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;font: normal normal 8pt 'Courier New', Courier, monospace; color: #003030;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #cc00cc;">#map</span> <span style="color: #66cc66;">&#123;</span></div></li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;font: normal normal 8pt 'Courier New', Courier, monospace; color: #003030;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #000000; font-weight: bold;">float</span> : <span style="color: #000000; font-weight: bold;">left</span>;</div></li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;font: normal normal 8pt 'Courier New', Courier, monospace; color: #003030;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #66cc66;">&#125;</span></div></li></ol></div></div>
<p>Ça y est! Vous devriez avoir une belle carte sur votre page! La prochaine fois nous modifierons le script pour générer les marqueurs <strong>dynamiquement </strong>en fonction d&#8217;une <strong>base de donnée</strong>.</p>
<p>Ça marche chez vous? Vous avez fait les fous en rajoutant une image provenant de chez flickr dans votre infobulle? Montrez moi tout ça!<!--:--></p>
<ul class="related_post"><li><a href="http://antoine.guiral.info/2008/01/19/tuto-mashup-galerie-photo-animee-via-flickr-recuperer-les-photos-12/" title="<!--:fr-->[tuto mashup] Galerie photo animée via Flickr : récupérer les photos (1/2)<!--:-->"><!--:fr-->[tuto mashup] Galerie photo animée via Flickr : récupérer les photos (1/2)<!--:--></a></li><li><a href="http://antoine.guiral.info/2008/05/02/tuto-jquery-navigation-en-ajax-non-intrusif-22/" title="<!--:fr-->[tuto jQuery] navigation en ajax non-intrusif (2/2)<!--:-->"><!--:fr-->[tuto jQuery] navigation en ajax non-intrusif (2/2)<!--:--></a></li><li><a href="http://antoine.guiral.info/2008/01/22/tuto-mashup-galerie-photo-animee-via-flickr-animer-votre-galerie-22/" title="<!--:fr-->[tuto mashup] Galerie photo animée via Flickr : animer votre galerie (2/2)<!--:-->"><!--:fr-->[tuto mashup] Galerie photo animée via Flickr : animer votre galerie (2/2)<!--:--></a></li><li><a href="http://antoine.guiral.info/2008/04/20/tuto-jquery-navigation-en-ajax-non-intrusif-12/" title="<!--:fr-->[tuto jQuery] navigation en ajax non-intrusif (1/2)<!--:-->"><!--:fr-->[tuto jQuery] navigation en ajax non-intrusif (1/2)<!--:--></a></li><li><a href="http://antoine.guiral.info/2008/03/09/tuto-jquery-drag-%e2%80%98n-drop-avec-sauvegarde-automatique-en-base-de-donnees-22/" title="<!--:fr-->[tuto jquery] drag ‘n drop avec sauvegarde automatique en base de données (2/2)<!--:-->"><!--:fr-->[tuto jquery] drag ‘n drop avec sauvegarde automatique en base de données (2/2)<!--:--></a></li><li><a href="http://antoine.guiral.info/2008/02/24/tuto-jquery-drag-n-drop-avec-sauvegarde-automatique-en-base-de-donnees-12/" title="<!--:fr-->[tuto jquery] drag ‘n drop avec sauvegarde automatique en base de données (1/2)<!--:-->"><!--:fr-->[tuto jquery] drag ‘n drop avec sauvegarde automatique en base de données (1/2)<!--:--></a></li><li><a href="http://antoine.guiral.info/2008/01/18/vous-avez-dit-mashup/" title="<!--:fr-->Vous avez dit mashup?<!--:-->"><!--:fr-->Vous avez dit mashup?<!--:--></a></li><li><a href="http://antoine.guiral.info/2008/01/17/annonce-prochain-tutoriel-flickrphpjquery-cest-pour-demain/" title="<!--:fr-->[annonce] Prochain tutoriel flickr/php/jquery : c&#8217;est pour demain!<!--:-->"><!--:fr-->[annonce] Prochain tutoriel flickr/php/jquery : c&#8217;est pour demain!<!--:--></a></li><li><a href="http://antoine.guiral.info/2008/04/20/tuto-flex-hello-world-en-flex-il-y-a-un-debut-a-tout/" title="<!--:fr-->[tuto flex] hello world en flex: il y a un début à tout!<!--:-->"><!--:fr-->[tuto flex] hello world en flex: il y a un début à tout!<!--:--></a></li><li><a href="http://antoine.guiral.info/2008/01/20/tuto-php-generer-des-images-png-dynamiquement-grace-a-php/" title="<!--:fr-->[tuto php] générer des images png dynamiquement grâce à php<!--:-->"><!--:fr-->[tuto php] générer des images png dynamiquement grâce à php<!--:--></a></li></ul>]]></content:encoded>
			<wfw:commentRss>http://antoine.guiral.info/2008/01/24/tuto-mashup-google-maps-sur-votre-site-cest-possible-version-statique/feed/</wfw:commentRss>
		<slash:comments>23</slash:comments>
		</item>
		<item>
		<title>[tuto php] générer des images png dynamiquement grâce à php</title>
		<link>http://antoine.guiral.info/2008/01/20/tuto-php-generer-des-images-png-dynamiquement-grace-a-php/</link>
		<comments>http://antoine.guiral.info/2008/01/20/tuto-php-generer-des-images-png-dynamiquement-grace-a-php/#comments</comments>
		<pubDate>Sat, 19 Jan 2008 23:33:04 +0000</pubDate>
		<dc:creator>Antoine</dc:creator>
				<category><![CDATA[PHP]]></category>
		<category><![CDATA[creation]]></category>
		<category><![CDATA[design]]></category>
		<category><![CDATA[internet]]></category>
		<category><![CDATA[tutoriel]]></category>
		<category><![CDATA[web]]></category>

		<guid isPermaLink="false">http://guiralantoine.wordpress.com/2008/01/20/tuto-php-generer-des-images-png-dynamiquement-grace-a-php/</guid>
		<description><![CDATA[Vous avez peut être déjà voulu faire des images qui changeraient en fonction d&#8217;un paramètre? Par exemple des images pour proposer des statistiques : vous passeriez le pourcentage et le script vous renverrais une image représentant vos données :  pour 75%. Eh bien vous pourrez bientôt le faire! Bien sûr ce tutoriel sera juste ]]></description>
			<content:encoded><![CDATA[<p><!--:fr-->Vous avez peut être déjà voulu faire des images qui changeraient en fonction d&#8217;un paramètre? Par exemple des images pour proposer des statistiques : vous passeriez le pourcentage et le script vous renverrais une image représentant vos données : <img src="http://www.e-caveavin.com/cv/tuto/img_stat.php?len=75" alt="" width="102" height="10" /> pour 75%. Eh bien vous pourrez bientôt le faire! Bien sûr ce tutoriel sera juste une base, à vous de réutiliser ce que vous aurez appris pour l&#8217;adapter à vos besoin.</p>
<ul>
<li>Configurer php : la librairie gd2</li>
</ul>
<p>Ouvrez votre fichier <span style="font-weight:bold;">php.ini</span> et <span style="font-weight:bold;">décommentez </span>(enlevez le &laquo;&nbsp;<span style="font-style:italic;">;</span>&nbsp;&raquo; en début de ligne) la ligne : <span style="font-weight:bold;">extension=php_gd2.dll</span>.</p>
<ul>
<li>le code!</li>
</ul>
<p>Tout d&#8217;abord il faut indiquer au navigateur le<strong> type MIME</strong> de ce que va retourner le serveur grâce aux &laquo;&nbsp;<strong>header</strong>&nbsp;&raquo; ou &laquo;&nbsp;<strong>en-tête</strong>&nbsp;&raquo; HTTP. Ici c&#8217;est une image <strong>png</strong>. Nous allons donc envoyer un header contenant le type et le sous-type : <strong>image/png</strong> avec php.</p>
<p><span style="color:#ff00ff;">&lt;?php</span><br />
<span style="color:#ff00ff;">header (&nbsp;&raquo;Content-type: image/png&nbsp;&raquo;);</span></p>
<p>Ensuite nous créons l&#8217;image avec la fonction <strong>imagecreate</strong>. Le premier argument est la largeur de l&#8217;image, le second est la hauteur.</p>
<p><span style="color:#ff00ff;">$image = imagecreate(102,10);</span></p>
<p>On définit maintenant les différentes couleurs qui seront utilisées par l&#8217;image (premier argument) en utilisant <strong>imagecolorallocate</strong>. La première allocation d&#8217;image définit la couleur de fond de l&#8217;image.</p>
<p><span style="color:#ff00ff;">$gris = imagecolorallocate($image, 199, 200, 199);</span><br />
<span style="color:#ff00ff;">$rouge = imagecolorallocate($image, 153,0, 0);</span><br />
<span style="color:#ff00ff;">$noir = imagecolorallocate($image, 0, 0, 0);</span></p>
<p>On va maintenant tracer le cadre noir autour de notre image avec la fonction <strong>ImageRectange</strong>. Le premier argument est l&#8217;image sur laquelle le rectangle va être tracer. Les deux suivant sont les coordonnées de l&#8217;angle supérieur gauche (0,0). Les deux suivant, ceux de l&#8217;angle inférieur droit (101,9).Nous avons bien une largeur de 102 et une hauteur de 10 : attention à l&#8217;origine des repères qui est bien (0,0). Le dernier argument est la couleur. On utilise les variables variables : $couleur vaut &laquo;&nbsp;noir&nbsp;&raquo; donc ${$couleur} vaudra &laquo;&nbsp;$noir&nbsp;&raquo; qui est bien la couleur allouée précédemment.</p>
<p><span style="color:#ff00ff;">$couleur=&nbsp;&raquo;noir&nbsp;&raquo;;</span><br />
<span style="color:#ff00ff;">ImageRectangle ($image, 0, 0, 101, 9, ${$couleur});</span></p>
<p>On répéte l&#8217;opération à quelques différences près : la fonction utilisée est <strong>ImageFilledRectangle </strong>qui construit un rectangle plein et non  juste les contours. De plus la largeur du rectangle (donc l&#8217;abscisse de l&#8217;angle inférieur droit) est envoyé en paramètre au script. Donc nous le récupérons avec la variable serveur $_GET['nom_de_largument'].</p>
<p><span style="color:#ff00ff;">$couleur=&nbsp;&raquo;rouge&nbsp;&raquo;;</span><br />
<span style="color:#ff00ff;">ImageFilledRectangle ($image, 1, 1, $_GET['len'], 8, ${$couleur});</span></p>
<p>Il ne reste plus qu&#8217;à renvoyer l&#8217;image au navigateur (c&#8217;est à dire la sortie standard dans notre cas) grâce à <strong>imagepng</strong>. Puis à libérer les ressources avec <strong>imagedestroy</strong>.</p>
<p style="color:#ff00ff;">imagepng($image);<br />
imagedestroy( $img );<br />
?&gt;</p>
<p style="color:#ff00ff;"><span style="color:#000000;">Ca y est! Vous pouvez utiliser votre image en indiquant, dans l&#8217;attribut src de la balise html, l&#8217;url de votre fichier avec en argument votre pourcentage. Par exemple : <span style="font-weight:bold;">&lt;img src=&nbsp;&raquo;http://www.e-caveavin.com/cv/tuto/img_stat.php?len=75&#8243; /&gt;<strong>.</strong></span></span></p>
<p style="color:#ff00ff;">
<p style="color:#ff00ff;"><span style="color: #000000;">Il existe <a title="Dans le menu de droite" href="http://www.manuelphp.com/php/function.imagepng.php" target="_blank">énormement de fonction</a> pour créer des formes ou du texte avec la librairie gd de php.</span></p>
<p style="color:#ff00ff;"><span style="color: #000000;">N&#8217;oubliez pas de poster vos créations!! Et si vous avez des questions comme d&#8217;hab&#8217;, un ptit commentaire :-p<br />
</span><!--:--></p>
<ul class="related_post"><li><a href="http://antoine.guiral.info/2008/05/02/tuto-jquery-navigation-en-ajax-non-intrusif-22/" title="<!--:fr-->[tuto jQuery] navigation en ajax non-intrusif (2/2)<!--:-->"><!--:fr-->[tuto jQuery] navigation en ajax non-intrusif (2/2)<!--:--></a></li><li><a href="http://antoine.guiral.info/2008/04/20/tuto-jquery-navigation-en-ajax-non-intrusif-12/" title="<!--:fr-->[tuto jQuery] navigation en ajax non-intrusif (1/2)<!--:-->"><!--:fr-->[tuto jQuery] navigation en ajax non-intrusif (1/2)<!--:--></a></li><li><a href="http://antoine.guiral.info/2008/03/09/tuto-jquery-drag-%e2%80%98n-drop-avec-sauvegarde-automatique-en-base-de-donnees-22/" title="<!--:fr-->[tuto jquery] drag ‘n drop avec sauvegarde automatique en base de données (2/2)<!--:-->"><!--:fr-->[tuto jquery] drag ‘n drop avec sauvegarde automatique en base de données (2/2)<!--:--></a></li><li><a href="http://antoine.guiral.info/2008/02/24/tuto-jquery-drag-n-drop-avec-sauvegarde-automatique-en-base-de-donnees-12/" title="<!--:fr-->[tuto jquery] drag ‘n drop avec sauvegarde automatique en base de données (1/2)<!--:-->"><!--:fr-->[tuto jquery] drag ‘n drop avec sauvegarde automatique en base de données (1/2)<!--:--></a></li><li><a href="http://antoine.guiral.info/2008/01/24/tuto-mashup-google-maps-sur-votre-site-cest-possible-version-statique/" title="<!--:fr-->[tuto mashup] Google maps sur votre site : c&#8217;est possible! (version statique)<!--:-->"><!--:fr-->[tuto mashup] Google maps sur votre site : c&#8217;est possible! (version statique)<!--:--></a></li><li><a href="http://antoine.guiral.info/2008/01/19/tuto-mashup-galerie-photo-animee-via-flickr-recuperer-les-photos-12/" title="<!--:fr-->[tuto mashup] Galerie photo animée via Flickr : récupérer les photos (1/2)<!--:-->"><!--:fr-->[tuto mashup] Galerie photo animée via Flickr : récupérer les photos (1/2)<!--:--></a></li><li><a href="http://antoine.guiral.info/2008/04/20/tuto-flex-hello-world-en-flex-il-y-a-un-debut-a-tout/" title="<!--:fr-->[tuto flex] hello world en flex: il y a un début à tout!<!--:-->"><!--:fr-->[tuto flex] hello world en flex: il y a un début à tout!<!--:--></a></li><li><a href="http://antoine.guiral.info/2008/01/22/tuto-mashup-galerie-photo-animee-via-flickr-animer-votre-galerie-22/" title="<!--:fr-->[tuto mashup] Galerie photo animée via Flickr : animer votre galerie (2/2)<!--:-->"><!--:fr-->[tuto mashup] Galerie photo animée via Flickr : animer votre galerie (2/2)<!--:--></a></li><li><a href="http://antoine.guiral.info/2008/01/18/vous-avez-dit-mashup/" title="<!--:fr-->Vous avez dit mashup?<!--:-->"><!--:fr-->Vous avez dit mashup?<!--:--></a></li><li><a href="http://antoine.guiral.info/2008/01/17/annonce-prochain-tutoriel-flickrphpjquery-cest-pour-demain/" title="<!--:fr-->[annonce] Prochain tutoriel flickr/php/jquery : c&#8217;est pour demain!<!--:-->"><!--:fr-->[annonce] Prochain tutoriel flickr/php/jquery : c&#8217;est pour demain!<!--:--></a></li></ul>]]></content:encoded>
			<wfw:commentRss>http://antoine.guiral.info/2008/01/20/tuto-php-generer-des-images-png-dynamiquement-grace-a-php/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>[tuto mashup] Galerie photo animée via Flickr : récupérer les photos (1/2)</title>
		<link>http://antoine.guiral.info/2008/01/19/tuto-mashup-galerie-photo-animee-via-flickr-recuperer-les-photos-12/</link>
		<comments>http://antoine.guiral.info/2008/01/19/tuto-mashup-galerie-photo-animee-via-flickr-recuperer-les-photos-12/#comments</comments>
		<pubDate>Sat, 19 Jan 2008 00:25:02 +0000</pubDate>
		<dc:creator>Antoine</dc:creator>
				<category><![CDATA[PHP]]></category>
		<category><![CDATA[2.0]]></category>
		<category><![CDATA[api]]></category>
		<category><![CDATA[découverte]]></category>
		<category><![CDATA[flickr]]></category>
		<category><![CDATA[internet]]></category>
		<category><![CDATA[mashup]]></category>
		<category><![CDATA[poo]]></category>
		<category><![CDATA[projet]]></category>
		<category><![CDATA[tutoriel]]></category>
		<category><![CDATA[web]]></category>

		<guid isPermaLink="false">http://guiralantoine.wordpress.com/2008/01/19/tuto-mashup-galerie-photo-animee-via-flickr-recuperer-les-photos-12/</guid>
		<description><![CDATA[Ça y est! Il est là, il est tout nouveau tout beau! Le tutoriel pour faire une galerie photo animée avec JQuery et qui utilise flickr pour héberger vos photos. Un bon petit mashup quoi! Pour voir ce que ça donne un peit test ici&#8230; Allé gogogogogo!

 Flickr

Bon, on veux héberger nos photos chez flickr. ]]></description>
			<content:encoded><![CDATA[<p><!--:fr-->Ça y est! Il est là, il est tout nouveau tout beau! Le <span style="font-weight:bold;">tutoriel </span>pour faire une <span style="font-weight:bold;">galerie photo animée</span> avec <span style="font-weight:bold;">JQuery </span>et qui utilise <a href="http://guiralantoine.wordpress.com/2008/01/16/gerez-et-partagez-vos-photos-avec-flickr-a-la-mode-20/" title="keskecékeca???" target="_blank">flickr</a> pour héberger vos photos. Un bon petit <span style="font-weight:bold;"><a href="http://guiralantoine.wordpress.com/2008/01/18/vous-avez-dit-mashup/" title="Kézako?" target="_blank">mashup</a> </span>quoi! Pour voir ce que ça donne un peit test<a href="http://www.e-caveavin.com/cv/test_flickr.php" title="Page de test toute bete^^" target="_blank"> ici</a>&#8230; Allé gogogogogo!</p>
<ul>
<li> Flickr</li>
</ul>
<p>Bon, on veux héberger nos photos chez <a href="http://www.flickr.com/" title="flickr" target="_blank">flickr</a>. Donc&#8230;il vous faut un compte flickr (si ce n&#8217;est déjà fait!). Allé hop hop hop on <a href="https://login.yahoo.com/config/login?.src=flickr&amp;.pc=5134&amp;.scrumb=0&amp;.pd=c%3DE0.GahOp2e4MjkX.5l2HgAoLkpmyPvccpVM-&amp;.intl=fr&amp;.done=https%3A%2F%2Flogin.yahoo.com%2Fconfig%2Fvalidate%3F.src%3Dflickr%26.pc%3D5134%26.scrumb%3D0%26.pd%3Dc%253DE0.GahOp2e4MjkX.5l2HgAoLkpmyPvccpVM-%26.intl%3Dfr%26.done%3Dhttp%253A%252F%252Fwww.flickr.com%252Fsignin%252Fyahoo%252F" title="Se connecter à flickr" target="_blank">s&#8217;inscrit</a>. Si vous avez un compte yahoo! cela devrait être ok. L&#8217; inscription ça c&#8217;est fait. Un petit mail de validation plus tard vous  voila connecter sur votre compte flickr.<br />
Pour la suite sur flickr je vous ai <a href="http://www.e-caveavin.com/cv/tuto/add_photo_flickr.html" title="Tuto vidéo à suivre absolument pour la suite et jusqu'à la fin!!" target="_blank">préparé un tutoriel vidéo</a>. Je vous conseille de le suivre <span style="font-weight:bold;">en entier</span>, surtout pour la fin!</p>
<ul>
<li>Le php</li>
</ul>
<p>Alors là on rentre dans le vif du sujet. Nous allons utiliser une classe php. Des notions de <a href="http://fr.wikipedia.org/wiki/Programmation_orient%C3%A9e_objet" title="POO chez wikipedia" target="_blank">POO</a> serait un plus mais si vous n&#8217;y connaissez rien en POO pas de problème vous pouvez continuer. Pour commencer vous devez <a href="http://www.e-caveavin.com/cv/tuto/flickr.rar" title="La classe php!!">&gt;&gt;télécharger la classe basée sur l&#8217;API de flickr&lt;&lt;</a>. C&#8217;est elle qui va nous permettre d&#8217;afficher nos photos. Créez vous un dossier dans lequel vous décompressez l&#8217;archive. Créez y aussi un nouveau fichier php, par exemple : test-flickr.php.</p>
<p><u><b>Activer la librairie curl</b></u> : Il faut à présent vérifier que votre serveur local soit configuré correctement. Ouvrez votre php.ini et trouvez le bloc qui contient toutes les extensions de php. Il faut ensuite décommenter (enlever le &laquo;&nbsp;;&nbsp;&raquo; au début de la ligne) la ligne suivante : <b>extension=php_curl.dll</b>. C&#8217;est presque fini. Allez dans votre dossier &laquo;&nbsp;php&nbsp;&raquo; dans easyPhp ou dans WAMP et copier les fichiers <b>libeay32.dll</b> et <b>ssleay32.dll</b> dans votre dossier windows/system32 ou windows/system suivant votre version de windows.</p>
<p><u><b>Place au code</b></u> :</p>
<p>La première ligne va concerner l&#8217;<span style="font-weight:bold;">inclusion </span>de notre classe :</p>
<p><span style="color:#ff00ff;">&lt;?php</span></p>
<p><span style="color:#ff00ff;">require(&#8217;flickr.php&#8217;);</span></p>
<p>Ensuite pour pouvoir utiliser l&#8217;API nous devons obtenir <span style="text-decoration:line-through;">une</span> <span style="font-weight:bold;">deux clés</span> (gratuites). C&#8217;est le cas pour la quasi-totalité des API.  La première clé s&#8217;obtient en remplissant <a href="http://flickr.com/services/api/key.gne" title="La première clé" target="_blank">ce formulaire</a> :</p>
<p><a href="http://guiralantoine.files.wordpress.com/2008/01/cle_1_flickr.jpg" title="La première clé!"></a></p>
<div style="text-align:center;"><a href="http://guiralantoine.files.wordpress.com/2008/01/cle_1_flickr.jpg" title="La première clé!"><img src="http://guiralantoine.files.wordpress.com/2008/01/cle_1_flickr.jpg" alt="La première clé!" border="0" height="450" width="650" /></a></div>
<p>La seconde clé suivez le lien indiquez par la flèche rouge. Elle se situe sous la première clé et s&#8217;appelle clé de &laquo;&nbsp;<span style="font-style:italic;">secret partagé</span>&laquo;&nbsp;. Nous pouvons maintenant nous connecter à flickr <span style="font-style:italic;">via</span> l&#8217;API.</p>
<p><span style="color:#00ff00;">// Paramètres API :</span></p>
<p><span style="color:#ff00ff;">$apiKey = &#8216;010e84b635468**********8d7a0f322&#8242;;</span><br />
<span style="color:#ff00ff;">$apiSecret = &#8216;989******aa1418e&#8217;;</span></p>
<p>La variable $apiKey correspond à la première clé. Pas la peine de traduire pour la seconde <img src='http://antoine.guiral.info/wp-includes/images/smilies/icon_wink.gif' alt=';-)' class='wp-smiley' /> .</p>
<p>Vous vous souvenez des id que vous avez notés au début? Re-sortez les!</p>
<p><span style="color:#00ff00;"> // Id du User :</span></p>
<p><span style="color:#ff00ff;">$userId = &#8216;227*****@N07&#8242;;</span></p>
<p><span style="color:#00ff00;">//Id de l&#8217;album :</span></p>
<p><span style="color:#ff00ff;">$albumId = &#8216;72157*********064&#8242;;</span></p>
<p>Nous y voilà. Nous allons <span style="font-weight:bold;">instancier</span> notre classe Flickr. C&#8217;est à dire que nous allons créer un <span style="font-weight:bold;">objet </span>à partir de notre classe. Voila comment ça se passe :</p>
<p><span style="color:#00ff00;">// Nouvelle instance de Flickr :</span></p>
<p><span style="color:#ff00ff;">$flickr = new Flickr( $apiKey , $apiSecret ); </span></p>
<p>Notre nouvel objet : $flickr. C&#8217;est lui qui gère la <span style="font-weight:bold;">connexion </span>avec l&#8217;API. On va créer une instance de notre album maintenant. Même combat sauf que la classe change de nom :</p>
<p><span style="color:#00ff00;"> // Nouvelle instance de Album :</span></p>
<p><span style="color:#ff00ff;">$album = new Album( $flickr , $albumId , $userId );</span></p>
<p>Enfin! Nous avons notre album. On comprend rapidement les arguments que l&#8217;on transmet lors de l&#8217;instance : notre objet $flickr pour se conecter, notre identifiant d&#8217;album $albumId et notre identifiant utilisateur $userId. On a donc ce qu&#8217;il nous faut pour accéder à nos photos : Notre objet $album.</p>
<p>Pour ce tutoriel j&#8217;utilise la <span style="font-weight:bold;">méthode getPhotos()</span>. C&#8217;est celle qui nous donne le plus de données utilisables. Pour le moment nous allons nous contenter d&#8217;afficher les miniatures de nos photos.</p>
<p><span style="color:#00ff00;">// Affiche les &laquo;&nbsp;thumbs&nbsp;&raquo; de toutes les photos de l&#8217;album :</span></p>
<p><span style="color:#ff00ff;">foreach( $album-&gt;getPhotos() as $photo ) {</span><br />
<span style="color:#ff00ff;">    echo $photo['imgThumbs'] ;</span><br />
<span style="color:#ff00ff;">}</span></p>
<p style="color:#ff00ff;">?&gt;</p>
<p style="color:#000000;">Le foreach permet d&#8217;assigner à la variable $photo chaque &laquo;&nbsp;ligne&nbsp;&raquo; ou &laquo;&nbsp;tuple&nbsp;&raquo; (pour reprendre un langage plus orienté base de données) renvoyés par la methode getPhotos(). Si vous voulez avoir le détail de ce que renvoi getPhotos() pour faire mumuz et modifier le script à votre guise, remplacez la ligne du echo par :</p>
<p style="color:#ff00ff;">var_dump($photo);</p>
<p style="color:#000000;">Un petit test dans <span style="text-decoration:line-through;">firefox</span> votre navigateur favori et normalement vous devriez avoir toutes vos miniatures!</p>
<p style="color:#000000;">Un grand merci à <a href="http://classes.scriptsphp.org/doc.flickr" title="La liste des methodes" target="_blank">scriptsphp</a> pour cette classe et la doc fournie. D&#8217;ailleurs n&#8217;hésitez pas à aller faire un tour sur leur site pour voir toutes les méthodes qui existent.</p>
<p style="color:#000000;">&nbsp;</p>
<p style="color:#000000;">La <span style="font-weight:bold;">prochaine étape</span> du tutoriel portera sur l&#8217;aspect <span style="font-weight:bold;">animation </span>de la gallerie histoire d&#8217;avoir un truc présentable!</p>
<p style="color:#000000;">Si vous avez fait des essais postez vos url&#8217;s en commentaire. Pareil si vous avez des bugs, problèmes remarques, etc etc n&#8217;hésitez surtout pas!! A très bientôt pour la suite!</p>
<p style="color:#000000;">&nbsp;</p>
<p style="color:#000000;"><u><b>EDIT</b></u> : <a href="http://guiralantoine.wordpress.com/2008/01/22/tuto-mashup-galerie-photo-animee-via-flickr-animer-votre-galerie-22/" title="La suite ici!" target="_blank">la suite est ici</a>!</p>
<p><!--:--></p>
<ul class="related_post"><li><a href="http://antoine.guiral.info/2008/01/24/tuto-mashup-google-maps-sur-votre-site-cest-possible-version-statique/" title="<!--:fr-->[tuto mashup] Google maps sur votre site : c&#8217;est possible! (version statique)<!--:-->"><!--:fr-->[tuto mashup] Google maps sur votre site : c&#8217;est possible! (version statique)<!--:--></a></li><li><a href="http://antoine.guiral.info/2008/01/18/vous-avez-dit-mashup/" title="<!--:fr-->Vous avez dit mashup?<!--:-->"><!--:fr-->Vous avez dit mashup?<!--:--></a></li><li><a href="http://antoine.guiral.info/2008/01/22/tuto-mashup-galerie-photo-animee-via-flickr-animer-votre-galerie-22/" title="<!--:fr-->[tuto mashup] Galerie photo animée via Flickr : animer votre galerie (2/2)<!--:-->"><!--:fr-->[tuto mashup] Galerie photo animée via Flickr : animer votre galerie (2/2)<!--:--></a></li><li><a href="http://antoine.guiral.info/2008/01/17/annonce-prochain-tutoriel-flickrphpjquery-cest-pour-demain/" title="<!--:fr-->[annonce] Prochain tutoriel flickr/php/jquery : c&#8217;est pour demain!<!--:-->"><!--:fr-->[annonce] Prochain tutoriel flickr/php/jquery : c&#8217;est pour demain!<!--:--></a></li><li><a href="http://antoine.guiral.info/2008/05/02/tuto-jquery-navigation-en-ajax-non-intrusif-22/" title="<!--:fr-->[tuto jQuery] navigation en ajax non-intrusif (2/2)<!--:-->"><!--:fr-->[tuto jQuery] navigation en ajax non-intrusif (2/2)<!--:--></a></li><li><a href="http://antoine.guiral.info/2008/01/16/gerez-et-partagez-vos-photos-avec-flickr-a-la-mode-20/" title="<!--:fr-->Gérez et partagez vos photos avec flickr à la mode 2.0<!--:-->"><!--:fr-->Gérez et partagez vos photos avec flickr à la mode 2.0<!--:--></a></li><li><a href="http://antoine.guiral.info/2008/04/20/tuto-flex-hello-world-en-flex-il-y-a-un-debut-a-tout/" title="<!--:fr-->[tuto flex] hello world en flex: il y a un début à tout!<!--:-->"><!--:fr-->[tuto flex] hello world en flex: il y a un début à tout!<!--:--></a></li><li><a href="http://antoine.guiral.info/2008/04/20/tuto-jquery-navigation-en-ajax-non-intrusif-12/" title="<!--:fr-->[tuto jQuery] navigation en ajax non-intrusif (1/2)<!--:-->"><!--:fr-->[tuto jQuery] navigation en ajax non-intrusif (1/2)<!--:--></a></li><li><a href="http://antoine.guiral.info/2008/03/09/tuto-jquery-drag-%e2%80%98n-drop-avec-sauvegarde-automatique-en-base-de-donnees-22/" title="<!--:fr-->[tuto jquery] drag ‘n drop avec sauvegarde automatique en base de données (2/2)<!--:-->"><!--:fr-->[tuto jquery] drag ‘n drop avec sauvegarde automatique en base de données (2/2)<!--:--></a></li><li><a href="http://antoine.guiral.info/2008/02/24/tuto-jquery-drag-n-drop-avec-sauvegarde-automatique-en-base-de-donnees-12/" title="<!--:fr-->[tuto jquery] drag ‘n drop avec sauvegarde automatique en base de données (1/2)<!--:-->"><!--:fr-->[tuto jquery] drag ‘n drop avec sauvegarde automatique en base de données (1/2)<!--:--></a></li></ul>]]></content:encoded>
			<wfw:commentRss>http://antoine.guiral.info/2008/01/19/tuto-mashup-galerie-photo-animee-via-flickr-recuperer-les-photos-12/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
	</channel>
</rss>
