<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0">
	<channel>
		<title>Retour à La Source • Tag: PHP • RSS</title>
		<link>http://www.ab-d.fr/tag/PHP/</link>
		<description>Retour à La Source • Tag: PHP • RSS</description>
		<copyright>http://www.ab-d.fr/tag/PHP/ (c) 2010</copyright>
		<language>fr</language>
		<pubDate>Sat, 31 Jul 2010 15:02:47 +0100</pubDate>
		<generator>Retour à La Source • Tag: PHP • RSS • version 1.0</generator>
		<webMaster>noreply@ab-d.fr ( Benoit Asselin )</webMaster>
		<image>
			<url>http://www.ab-d.fr/images/rss.gif</url>
			<title>Retour à La Source • Tag: PHP • RSS</title>
			<link>http://www.ab-d.fr/tag/PHP/</link>
			<width>90</width>
			<height>30</height>
		</image>

		<item>
			<title>La fonction date() PHP traduite en français ( PHP, date )</title>
			<link>http://www.ab-d.fr/date/2010-02-01/</link>
			<pubDate>Mon, 01 Feb 2010 09:00:00 +0100</pubDate>
			<author>noreply@ab-d.fr ( Benoit Asselin )</author>
			<category><![CDATA[PHP]]></category>
			<description><![CDATA[<p>
Cette fonction se comporte exactement de la même manière que la fonction <code>date()</code> en PHP, mais traduite en français.
</p>
<pre>
function date_french($format, $timestamp = null) {
	$param_D = array('', 'Lun', 'Mar', 'Mer', 'Jeu', 'Ven', 'Sam', 'Dim');
	$param_l = array('', 'Lundi', 'Mardi', 'Mercredi', 'Jeudi', 'Vendredi', 'Samedi', 'Dimanche');
	$param_F = array('', 'Janvier', 'F&amp;eacute;vrier', 'Mars', 'Avril', 'Mai', 'Juin', 'Juillet', 'Ao&amp;ucirc;t', 'Septembre', 'Octobre', 'Novembre', 'D&amp;eacute;cembre');
	$param_M = array('', 'Jan', 'F&amp;eacute;v', 'Mar', 'Avr', 'Mai', 'Jun', 'Jul', 'Ao&amp;ucirc;', 'Sep', 'Oct', 'Nov', 'D&amp;eacute;c');

	$return = '';
	if(is_null($timestamp)) { $timestamp = mktime(); }
	for($i = 0, $len = strlen($format); $i < $len; $i++) {
		switch($format[$i]) {
			case '\\\\\\' : // double.slashes
				$i++;
				$return .= isset($format[$i]) ? $format[$i] : '';
				break;
			case 'D' :
				$return .= $param_D[date('N', $timestamp)];
				break;
			case 'l' :
				$return .= $param_l[date('N', $timestamp)];
				break;
			case 'F' :
				$return .= $param_F[date('n', $timestamp)];
				break;
			case 'M' :
				$return .= $param_M[date('n', $timestamp)];
				break;
			default :
				$return .= date($format[$i], $timestamp);
				break;
		}
	}
	return $return;
}

</pre>

<hr />
<a href="http://res.feedsportal.com/viral/bookmark_fr.cfm?link=http%3A%2F%2Fwww.ab-d.fr%2Fdate%2F2010-02-01%2F&title=La+fonction+date%28%29+PHP+traduite+en+fran%C3%A7ais+%28+PHP%2C+date+%29"><img src="http://www.ab-d.fr/images/bookmark.gif" border="0" /></a><br /><br />]]></description>
			<comments>http://www.ab-d.fr/tag/PHP/</comments>
			<guid isPermaLink="false">http://www.ab-d.fr/date/2010-02-01/</guid>
		</item>

		<item>
			<title>Comment lire des données POST bruts en PHP ( flux, php://input )</title>
			<link>http://www.ab-d.fr/date/2008-09-09/</link>
			<pubDate>Tue, 09 Sep 2008 14:56:32 +0100</pubDate>
			<author>noreply@ab-d.fr ( Benoit Asselin )</author>
			<category><![CDATA[PHP]]></category>
			<description><![CDATA[<p>
Voici sûrement l'une des astuces les plus inutiles du moment. Comment accéder aux données <code>POST</code> bruts en PHP ? Il suffit de lire le flux d'entrée <code>php://input</code> de la manière suivante :
</p>

<pre>
&lt;form action="page-input.php" method="post"&gt;
	&lt;p&gt;
		&lt;label for="text"&gt;Zone de texte :&lt;/label&gt;
		&lt;input type="text" name="text" id="text" /&gt;
	&lt;/p&gt;
	
	&lt;p&gt;&lt;input type="submit" name="submit" value="Continuer" /&gt;&lt;/p&gt;
&lt;/form&gt;

&lt;p&gt;&lt;?php echo file_get_contents('php://input'); ?&gt;&lt;/p&gt;

</pre>

<p>
Ce qui retournera comme résultat :
</p>
<pre>
text=bla+bla+bla&amp;submit=Continuer
</pre>

<p>
<code>php://input</code> ne fonctionnera pas si vous utilisez l'attribut <code>enctype="multipart/form-data"</code> dans votre balise <code>&lt;form action="" method="post"&gt;</code>.
</p>
<p>
Documentation officielle : http://www.php.net/wrappers.php<br />
</p>

<hr /><a href="http://res.feedsportal.com/viral/bookmark_fr.cfm?link=http%3A%2F%2Fwww.ab-d.fr%2Fdate%2F2008-09-09%2F&title=Comment+lire+des+donn%C3%A9es+POST+bruts+en+PHP+%28+flux%2C+php%3A%2F%2Finput+%29"><img src="http://www.ab-d.fr/images/bookmark.gif" border="0" /></a><br /><br />]]></description>
			<comments>http://www.ab-d.fr/tag/PHP/</comments>
			<guid isPermaLink="false">http://www.ab-d.fr/date/2008-09-09/</guid>
		</item>

		<item>
			<title>Utiliser l'écriture Array sous forme Object en PHP ( PHP5, POO, ArrayAccess )</title>
			<link>http://www.ab-d.fr/date/2008-08-25/</link>
			<pubDate>Mon, 25 Aug 2008 10:26:26 +0100</pubDate>
			<author>noreply@ab-d.fr ( Benoit Asselin )</author>
			<category><![CDATA[PHP5]]></category>
			<category><![CDATA[PHP]]></category>
			<description><![CDATA[<p>
Comme annoncé la semaine dernière et les vacances se terminant, il est maintenant temps de remonter <em>(un peu)</em> le niveau de ce blog qui sombrait doucement mais sûrement dans le grand n'importe quoi.
</p>
<p>
L'astuce du jour n'est guère facile à expliquer en quelques lignes, un exemple sera à mon avis beaucoup plus clair.<br />
Comment utiliser un tableau comme un pur objet ? ( à la sauce Java, si je puis m'exprimer ainsi )
</p>

<pre>
// Ecriture PHP classique
$array = array(); // Ligne facultative
$array['key1'] = 'value 1';
$array['key2'] = 'value 2';
$array['key3']['key31'] = 'value 31';
...
</pre>

<p>Voici une écriture qui ne fonctionne qu'en PHP 5 :</p>
<pre>
// Ecriture PHP5 objet
$array = new ClassArray(); // Ligne obligatoire !
$array['key1'] = 'value 1';
$array['key2'] = 'value 2';
...
</pre>

<p>En soit, il n'y a absolument rien de révolutionnaire, mais le <code>new</code> crée l'instance de l'objet <code>ClassArray()</code> et vous pouvez constater que l'écriture reste un tableau et non un objet<br />
<code>$array->key1 = 'value 1';</code></p>

<p>Une question se pose sûrement dans votre cerveau qui bouillonne d'impatience : Qui a-t-il dans cette <code>ClassArray()</code> ? Une simple implémentation de <code>ArrayAccess</code> ( PHP5 only ), ce qui nous donne :</p>

<pre>
class ClassArray <strong>implements ArrayAccess</strong> {
	
	protected $_array = array();
	
	public function __construct() {
		$this->_array = func_get_args();
	}
	
	// En cas d'appel de la fonction isset()
	public function offsetExists($offset) {
		return isset($this->_array[$offset]);
	}
	
	// En cas d'appel de la valeur
	public function offsetGet($offset) {
		return $this->_array[$offset];
	}
	
	// En cas d'affectation de la valeur
	public function offsetSet($offset, $value) {
		return $this->_array[$offset] = $value;
	}
	
	// En cas d'appel de la fonction unset()
	public function offsetUnset($offset) {
		unset($this->_array[$offset]);
	}
	
}
</pre>

<p>Ensuite, libre à vous de modifier cette classe pour lui ajouter de nouvelles fonctionnalités...</p>

<p>Remarque importante : Si vous essayez de créer un tableau sur plusieurs dimensions, un message d'erreur se produira avec l'écriture suivante :</p>
<pre>
$array = new ClassArray();
$array['key3']['key31'] = 'value 31';

// Problème : Vous n'avez pas définit $array['key3'] ! l'écriture POO est beaucoup plus stricte ;)
// Solution :
$array = new ClassArray();
$array['key3'] = new ClassArray();
$array['key3']['key31'] = 'value 31';

</pre>

<p>
Documentation officielle :<br />
http://www.php.net/~helly/php/ext/spl/interfaceArrayAccess.html
</p>

<hr />

<a href="http://res.feedsportal.com/viral/bookmark_fr.cfm?link=http%3A%2F%2Fwww.ab-d.fr%2Fdate%2F2008-08-25%2F&title=Utiliser+l%27%C3%A9criture+Array+sous+forme+Object+en+PHP+%28+PHP5%2C+POO%2C+ArrayAccess+%29"><img src="http://www.ab-d.fr/images/bookmark.gif" border="0" /></a><br /><br />]]></description>
			<comments>http://www.ab-d.fr/tag/PHP/</comments>
			<guid isPermaLink="false">http://www.ab-d.fr/date/2008-08-25/</guid>
		</item>

		<item>
			<title>function array2object(array $array) { ... } en PHP5 ( object, stdClass, php )</title>
			<link>http://www.ab-d.fr/date/2008-07-19/</link>
			<pubDate>Sat, 19 Jul 2008 10:10:10 +0100</pubDate>
			<author>noreply@ab-d.fr ( Benoit Asselin )</author>
			<category><![CDATA[PHP]]></category>
			<category><![CDATA[PHP5]]></category>
			<description><![CDATA[<p>
Cette fonction <code>function array2object()</code> n'est pas nouvelle en soit, mais voici une écriture récursive en PHP5 plus rigolote ( <em>et surtout plus restrictive</em> ) à utiliser.</p>
<p>
La fonction ci-dessous ne fonctionne qu'en PHP 5 de part le typage du paramètre <code>(<strong>array</strong> $array)</code> ainsi on évite le contrôle <code>is_array()</code>. Toutefois, si vous envoyez une valeur qui n'est pas un tableau, une erreur de compilation se produira.
</p>

<pre>
function array2object(array $array) {
	$object = new stdClass();
	foreach($array as $key =&gt; $value) {
		if(is_array($value)) {
			$object-&gt;$key = array2object($value);
		} else {
			$object-&gt;$key = $value;
		}
	}
	return $object;
}
</pre>

<p>Exemples d'utilisation :</p>
<pre>
$tableau[0] = 'Valeur 0';
$tableau[1] = 'Valeur 1';
$tableau['deux'] = 'Valeur 2';
$tableau['trois'] = 'Valeur 3';

$objet = array2object($tableau);

echo $objet-&gt;0;     // Ecriture incorrecte
echo $objet-&gt;{'1'}; // Ecriture correcte
echo $objet-&gt;deux;  // Ecriture classique
echo $objet-&gt;trois; // etc...
</pre>

<hr /><a href="http://res.feedsportal.com/viral/bookmark_fr.cfm?link=http%3A%2F%2Fwww.ab-d.fr%2Fdate%2F2008-07-19%2F&title=function+array2object%28array+%24array%29+%7B+...+%7D+en+PHP5+%28+object%2C+stdClass%2C+php+%29"><img src="http://www.ab-d.fr/images/bookmark.gif" border="0" /></a><br /><br />]]></description>
			<comments>http://www.ab-d.fr/tag/PHP/</comments>
			<guid isPermaLink="false">http://www.ab-d.fr/date/2008-07-19/</guid>
		</item>

		<item>
			<title>Comment retourner plusieurs valeurs depuis une fonction PHP ? ( function )</title>
			<link>http://www.ab-d.fr/date/2008-07-05/</link>
			<pubDate>Sat, 05 Jul 2008 17:17:17 +0100</pubDate>
			<author>noreply@ab-d.fr ( Benoit Asselin )</author>
			<category><![CDATA[PHP]]></category>
			<description><![CDATA[<p>
Astuce du jour : Comment retourner plusieurs variables depuis une fonction PHP ?
</p>

<p>
Vous pouvez utiliser les tableaux <code>array()</code> ou les objets <code>new stdClass()</code> dans une variable et retourner la dite variable, toutefois cette écriture n'est pas forcément limpide lors d'une relecture de code.
</p>

<p>Je vous propose une écriture assez souple et surtout beaucoup plus claire qui vous donnera une réelle impression de <code>return</code> avec X valeurs.
</p>

<pre>
&lt;?php

function retourner_plusieurs_valeurs() {
	$variable_n_1 = 'One';
	$variable_n_2 = 'Two';
	$variable_n_3 = '333';
	
	return array(<strong>$variable_n_1, $variable_n_2, $variable_n_3</strong>);
}


list(<strong>$variable_n_1, $variable_n_2, $variable_n_3</strong>) = retourner_plusieurs_valeurs();

?&gt;

</pre>

<hr /><a href="http://res.feedsportal.com/viral/bookmark_fr.cfm?link=http%3A%2F%2Fwww.ab-d.fr%2Fdate%2F2008-07-05%2F&title=Comment+retourner+plusieurs+valeurs+depuis+une+fonction+PHP+%3F+%28+function+%29"><img src="http://www.ab-d.fr/images/bookmark.gif" border="0" /></a><br /><br />]]></description>
			<comments>http://www.ab-d.fr/tag/PHP/</comments>
			<guid isPermaLink="false">http://www.ab-d.fr/date/2008-07-05/</guid>
		</item>

		<item>
			<title>Formater un nombre au format monétaire ( money_format, php )</title>
			<link>http://www.ab-d.fr/date/2008-06-28/</link>
			<pubDate>Sat, 28 Jun 2008 22:00:22 +0100</pubDate>
			<author>noreply@ab-d.fr ( Benoit Asselin )</author>
			<category><![CDATA[PHP]]></category>
			<description><![CDATA[<p>
Cette astuce n'a absolument rien d'extraordinaire, mais peut être vous fera-t-elle découvrir les différentes manières de formater un nombre au format monétaire.
</p>

<pre>
&lt;?php

$number = 1234.567;


// Première méthode ( peu pratique )
echo sprintf('%.2f &amp;euro;', $number); // 1234.57 €


// Seconde méthode ( plus simple mais non automatique )
echo number_format($number, 2, ',', ' ') . ' &amp;euro;'; // 1 234,57 €


// Troisième méthode ( qui peut être automatisée )
setlocale(LC_MONETARY, 'en_US');
echo money_format('%n', $number); // &#36;1,234.57

setlocale(LC_MONETARY, 'fr_FR');
echo money_format('%n', $number); // 1 234,57 Eu
echo money_format('%!n &amp;euro;', $number); // 1 234,57 €

?&gt;
</pre>

<p>
<em>Article inspiré du livre O'Reilly PHP Cookbook, Second Edition.</em>
</p>

<hr /><a href="http://res.feedsportal.com/viral/bookmark_fr.cfm?link=http%3A%2F%2Fwww.ab-d.fr%2Fdate%2F2008-06-28%2F&title=Formater+un+nombre+au+format+mon%C3%A9taire+%28+money_format%2C+php+%29"><img src="http://www.ab-d.fr/images/bookmark.gif" border="0" /></a><br /><br />]]></description>
			<comments>http://www.ab-d.fr/tag/PHP/</comments>
			<guid isPermaLink="false">http://www.ab-d.fr/date/2008-06-28/</guid>
		</item>

		<item>
			<title>Enlever les magic_quotes de $_GET, $_POST, $_COOKIE, $_REQUEST ( php6 )</title>
			<link>http://www.ab-d.fr/date/2008-05-25/</link>
			<pubDate>Sun, 25 May 2008 23:50:50 +0100</pubDate>
			<author>noreply@ab-d.fr ( Benoit Asselin )</author>
			<category><![CDATA[PHP]]></category>
			<description><![CDATA[<p>
Voici une petite commande PHP qui vous permettra de désactiver ou plutôt de nettoyer les magic_quotes quand ces dernières sont activées <em>( et accessoirement de préparer votre code si la fonction <code>get_magic_quotes_gpc()</code> venait à disparaître dans PHP 6 )</em>.
</p>
<pre>
if(!function_exists('get_magic_quotes_gpc')) {
	// En prevision de PHP 6
	function get_magic_quotes_gpc() { return 0; }
}

if(get_magic_quotes_gpc()) {
	function undo_magic_quotes(&amp;$array) {
		foreach($array as $key => $value) {
			if(is_array($array[$key])) {
				undo_magic_quotes($array[$key]);
			} else {
				$array[$key] = stripslashes($value);
			}
		}
	}
	
	undo_magic_quotes($_GET);
	undo_magic_quotes($_POST);
	undo_magic_quotes($_COOKIE);
	undo_magic_quotes($_REQUEST);
	undo_magic_quotes($_FILES);
}
</pre>

<hr /><a href="http://res.feedsportal.com/viral/bookmark_fr.cfm?link=http%3A%2F%2Fwww.ab-d.fr%2Fdate%2F2008-05-25%2F&title=Enlever+les+magic_quotes+de+%24_GET%2C+%24_POST%2C+%24_COOKIE%2C+%24_REQUEST+%28+php6+%29"><img src="http://www.ab-d.fr/images/bookmark.gif" border="0" /></a><br /><br />]]></description>
			<comments>http://www.ab-d.fr/tag/PHP/</comments>
			<guid isPermaLink="false">http://www.ab-d.fr/date/2008-05-25/</guid>
		</item>

		<item>
			<title>Créer / convertir des adresses de sites internet HTTP en liens cliquables</title>
			<link>http://www.ab-d.fr/date/2008-03-23/</link>
			<pubDate>Sun, 23 Mar 2008 04:03:02 +0100</pubDate>
			<author>noreply@ab-d.fr ( Benoit Asselin )</author>
			<category><![CDATA[PHP]]></category>
			<category><![CDATA[Regex]]></category>
			<category><![CDATA[XHTML]]></category>
			<description><![CDATA[<p>
La fonction ci-dessous vous permet par l'intérmédiaire des expressions régulières de convertir automatiquement les adresses de sites internet <code>http://www.ab-d.fr/</code> en lien actif avec la balise <code>&lt;a href="http://www.ab-d.fr/"  onclick="window.open(this.href); return false;"&gt;http://www.ab-d.fr/&lt;/a&gt;</code>.
</p>
<p>
Accessoirement, la fonction convertit aussi les adresses emails... libre à vous de rajouter d'autres fonctionnalités de remplacement grâce à la fonction <code>preg_replace()</code>.</p>
<pre>
function texte2url($texte) {
	$patterns[0] = '/(https?:\/\/\S+)/i';
	$replacements[0] = '&lt;a href="&#x24;1" onclick="window.open(this.href); return false;"&gt;&#x24;1&lt;/a&gt;';
	
	$patterns[1] = '/(\S+@\S+\.\S+)/i';
	$replacements[1] = '&lt;a href="mailto:&#x24;1"&gt;&#x24;1&lt;/a&gt;';
	
	return preg_replace($patterns, $replacements, $texte);
}

</pre>

<hr /><a href="http://res.feedsportal.com/viral/bookmark_fr.cfm?link=http%3A%2F%2Fwww.ab-d.fr%2Fdate%2F2008-03-23%2F&title=Cr%C3%A9er+%2F+convertir+des+adresses+de+sites+internet+HTTP+en+liens+cliquables"><img src="http://www.ab-d.fr/images/bookmark.gif" border="0" /></a><br /><br />]]></description>
			<comments>http://www.ab-d.fr/tag/PHP/</comments>
			<guid isPermaLink="false">http://www.ab-d.fr/date/2008-03-23/</guid>
		</item>

		<item>
			<title>Equivalent de parseInt en PHP avec preg_match (PHP, Regex, Javascript)</title>
			<link>http://www.ab-d.fr/date/2008-03-15/</link>
			<pubDate>Sat, 15 Mar 2008 18:52:52 +0100</pubDate>
			<author>noreply@ab-d.fr ( Benoit Asselin )</author>
			<category><![CDATA[PHP]]></category>
			<category><![CDATA[Regex]]></category>
			<description><![CDATA[<p>
La fonction <code>parseInt()</code> en Javascript tansforme une chaîne de caractères en nombre entier et renvoie la valeur numérique de celle-ci comme résultat.
Le plus proche équivalent en PHP est la fonction <code>intval()</code>. Toutefois, le résultat retourné me semble trop restrictif avec des chaînes de caractères ne débutant pas par un nombre.
Les expressions rationnelles (ou expressions régulières) permettent de outre passer cette limitation. Pour ce faire, on utilise la fonction <code>preg_match()</code> :
</p>
<pre>
function parseInt($string) {
//	return intval($string);
	if(preg_match('/(\d+)/', $string, $array)) {
		return $array[1];
	} else {
		return 0;
	}
}

echo parseInt("2008");
echo parseInt("soit 99.90 francs");
echo parseInt("www.w3.org");
echo parseInt("300 soldats spartiates");
echo parseInt("du texte brut...");

</pre>

<p>Ce script affichera comme résultat : <br />
- 2008<br />
- 99<br />
- 3<br />
- 300<br />
- 0<br />
</p>

<hr /><a href="http://res.feedsportal.com/viral/bookmark_fr.cfm?link=http%3A%2F%2Fwww.ab-d.fr%2Fdate%2F2008-03-15%2F&title=Equivalent+de+parseInt+en+PHP+avec+preg_match+%28PHP%2C+Regex%2C+Javascript%29"><img src="http://www.ab-d.fr/images/bookmark.gif" border="0" /></a><br /><br />]]></description>
			<comments>http://www.ab-d.fr/tag/PHP/</comments>
			<guid isPermaLink="false">http://www.ab-d.fr/date/2008-03-15/</guid>
		</item>

		<item>
			<title>$_SERVER['PHP_SELF'] et injection de code HTML (création site internet)</title>
			<link>http://www.ab-d.fr/date/2008-03-02/</link>
			<pubDate>Sun, 02 Mar 2008 04:24:24 +0100</pubDate>
			<author>noreply@ab-d.fr ( Benoit Asselin )</author>
			<category><![CDATA[PHP]]></category>
			<category><![CDATA[XHTML]]></category>
			<category><![CDATA[Securite]]></category>
			<description><![CDATA[<p>
Cette faille de sécurité n'est pas nouvelle en soit, mais il est parfois bon de faire un petit rappel. De manière générale, ne faites jamais confiance aux variables <code>$_SERVER</code>, <code>$_COOKIE</code>, mais aussi, <code>$_GET</code>, <code>$_POST</code>, <code>$_REQUEST</code>, <code>$_FILES</code>...
</p>
<p>
Exemple de faille avec <code>&lt;?php echo $_SERVER['PHP_SELF']; ?&gt;</code> dans la page php suivante :
</p>
<pre>
&lt;!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN"
   "http://www.w3.org/TR/html4/strict.dtd"&gt;

&lt;html lang="fr"&gt;
&lt;head&gt;
	&lt;meta http-equiv="Content-Type" content="text/html; charset=utf-8"&gt;
	&lt;title&gt;$_SERVER['PHP_SELF']&lt;/title&gt;
&lt;/head&gt;
&lt;body&gt;
	&lt;form action="&lt;?php echo $_SERVER['PHP_SELF']; ?&gt;" action="post"&gt;
		&lt;fieldset&gt;
			&lt;legend&gt;Ma FORM&lt;/legend&gt;
			&lt;p&gt;&lt;input type="submit"&gt;&lt;/p&gt;
		&lt;/fieldset&gt;
	&lt;/form&gt;
&lt;/body&gt;
&lt;/html&gt;
</pre>

<p>Si vous appelez la page ci-dessus avec le lien suivant :</p>
<pre>http://www.monsite.com/page.php/"&gt;&lt;script&gt;alert('Injection!');&lt;/script&gt;</pre>
<p>vous verrez une belle fenêtre de dialogue Javascript "Injection!" ...</p>

<p>Pour remédier à cette faille de sécurité, pensez à toujours sécuriser vos variables avec une fonction du type <code>htmlentities()</code>.</p>

<hr /><a href="http://res.feedsportal.com/viral/bookmark_fr.cfm?link=http%3A%2F%2Fwww.ab-d.fr%2Fdate%2F2008-03-02%2F&title=%24_SERVER%5B%27PHP_SELF%27%5D+et+injection+de+code+HTML+%28cr%C3%A9ation+site+internet%29"><img src="http://www.ab-d.fr/images/bookmark.gif" border="0" /></a><br /><br />]]></description>
			<comments>http://www.ab-d.fr/tag/PHP/</comments>
			<guid isPermaLink="false">http://www.ab-d.fr/date/2008-03-02/</guid>
		</item>

		<item>
			<title>Comment créer une variable CSS - Cascading Style Sheets ?</title>
			<link>http://www.ab-d.fr/date/2008-02-06/</link>
			<pubDate>Wed, 06 Feb 2008 18:43:34 +0100</pubDate>
			<author>noreply@ab-d.fr ( Benoit Asselin )</author>
			<category><![CDATA[CSS]]></category>
			<category><![CDATA[PHP]]></category>
			<category><![CDATA[XHTML]]></category>
			<description><![CDATA[<p>
La solution consiste n'ont pas à créer une variable CSS, mais à utiliser PHP pour créer des variables dans le code CSS.
Pour ce faire, nous allons utiliser l'écriture simplifiée de <br />
<code>&lt;?php echo $variable_css; ?&gt;</code> &nbsp; en &nbsp; <code>&lt;?= $variable_css ?&gt;</code> .
</p>

<p><br />Page <strong>page.html</strong></p>
<pre>
&lt;!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
	"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"&gt;

&lt;html xmlns="http://www.w3.org/1999/xhtml" xml:lang="fr" lang="fr"&gt;
&lt;head&gt;
	&lt;meta http-equiv="Content-Type" content="text/html; charset=utf-8"/&gt;
	
	&lt;title&gt;Variable CSS - Cascading Style Sheets&lt;/title&gt;
	&lt;link rel="stylesheet" type="text/css" href="style.php" /&gt;
&lt;/head&gt;

&lt;body&gt;


&lt;h1&gt;Variable CSS - Cascading Style Sheets&lt;/h1&gt;

&lt;p class="color-1"&gt;Bloc de couleur n&deg;1 - Variable CSS Cascading Style Sheets&lt;/p&gt;

&lt;p class="color-2"&gt;Bloc de couleur n&deg;2 - Variable CSS Cascading Style Sheets&lt;/p&gt;

&lt;p class="color-3"&gt;Bloc de couleur n&deg;3 - Variable CSS Cascading Style Sheets&lt;/p&gt;


&lt;/body&gt;

&lt;/html&gt;
</pre>

<p><br />Page <strong>style.php</strong> et non <del>style.css</del></p>
<pre>
&lt;?php
header('Content-Type: text/css');

$color_0 = '#000000';
$color_1 = '#ff0000';
$color_2 = '#ff3300';
$color_3 = '#ff6600';

?&gt;

* { font-family: sans-serif; }

h1 {
	padding: 5px;
	color: &lt;?= $color_0 ?&gt;;
	border: 5px solid &lt;?= $color_2 ?&gt;;
	background-color: &lt;?= $color_3 ?&gt;;
}

p.color-1 { color: &lt;?= $color_1 ?&gt;; }
p.color-2 { color: &lt;?= $color_2 ?&gt;; font-weight: bold; }
p.color-3 { color: &lt;?= $color_3 ?&gt;; font-style: italic; }

</pre>

<hr /><a href="http://res.feedsportal.com/viral/bookmark_fr.cfm?link=http%3A%2F%2Fwww.ab-d.fr%2Fdate%2F2008-02-06%2F&title=Comment+cr%C3%A9er+une+variable+CSS+-+Cascading+Style+Sheets+%3F"><img src="http://www.ab-d.fr/images/bookmark.gif" border="0" /></a><br /><br />]]></description>
			<comments>http://www.ab-d.fr/tag/PHP/</comments>
			<guid isPermaLink="false">http://www.ab-d.fr/date/2008-02-06/</guid>
		</item>

		<item>
			<title>PHP 6 sera disponible le premier trimestre 2008 selon Rasmus Lerdorf</title>
			<link>http://www.ab-d.fr/date/2008-01-23/</link>
			<pubDate>Wed, 23 Jan 2008 18:40:40 +0100</pubDate>
			<author>noreply@ab-d.fr ( Benoit Asselin )</author>
			<category><![CDATA[Actualites]]></category>
			<category><![CDATA[PHP]]></category>
			<description><![CDATA[<p>La nouvelle version de PHP devrait arriver durant le premier trimestre 2008 (<em>mois de mars ?</em>) selon son créateur Rasmus Lerdorf. L'annonce a été faite au cours du dernier Forum PHP à Paris.</p>

<p>Au menu, nous aurons le support Unicode et les namespaces, de meilleurs performances, toujours plus de sécurité (<em>l'évidence même dirons certains</em>), et... pour d'autres développeurs, une très mauvaise nouvelle: la suppression pur et simple des <code>magic_quotes</code> (<em>l'utilisation de <code>addslashes</code> sera donc de rigueur pour vos requêtes SQL</em>).</p>

<p>En attendant, la version 5.3 ne devrait pas tarder à sortir des cartons de PHP.net</p>

<p>Le chiffre du mois : En  décembre 2007, les statistiques de diffusion de PHP 5 dans le monde ne représentaient toujours que 28 % ...</p>

<hr /><a href="http://res.feedsportal.com/viral/bookmark_fr.cfm?link=http%3A%2F%2Fwww.ab-d.fr%2Fdate%2F2008-01-23%2F&title=PHP+6+sera+disponible+le+premier+trimestre+2008+selon+Rasmus+Lerdorf"><img src="http://www.ab-d.fr/images/bookmark.gif" border="0" /></a><br /><br />]]></description>
			<comments>http://www.ab-d.fr/tag/PHP/</comments>
			<guid isPermaLink="false">http://www.ab-d.fr/date/2008-01-23/</guid>
		</item>

		<item>
			<title>Fonction PHP trim() en JavaScript (prototype, function)</title>
			<link>http://www.ab-d.fr/date/2008-01-14/</link>
			<pubDate>Mon, 14 Jan 2008 10:10:10 +0100</pubDate>
			<author>noreply@ab-d.fr ( Benoit Asselin )</author>
			<category><![CDATA[Javascript]]></category>
			<category><![CDATA[PHP]]></category>
			<description><![CDATA[<pre>
String.prototype.trim = function() {
	return this.replace(/^\s*|\s*$/g, '');
};
</pre>
Exemple
<pre>
var v_string = ' Hello World ! ';
document.writeln('"' + v_string.trim() + '"');	// "Hello World !"
</pre>
<hr /><a href="http://res.feedsportal.com/viral/bookmark_fr.cfm?link=http%3A%2F%2Fwww.ab-d.fr%2Fdate%2F2008-01-14%2F&title=Fonction+PHP+trim%28%29+en+JavaScript+%28prototype%2C+function%29"><img src="http://www.ab-d.fr/images/bookmark.gif" border="0" /></a><br /><br />]]></description>
			<comments>http://www.ab-d.fr/tag/PHP/</comments>
			<guid isPermaLink="false">http://www.ab-d.fr/date/2008-01-14/</guid>
		</item>

		<item>
			<title>PHP 4 s'arrête ! Point final prévu pour le 8/8/8</title>
			<link>http://www.ab-d.fr/date/2008-01-03/</link>
			<pubDate>Thu, 03 Jan 2008 00:00:00 +0100</pubDate>
			<author>noreply@ab-d.fr ( Benoit Asselin )</author>
			<category><![CDATA[Actualites]]></category>
			<category><![CDATA[PHP]]></category>
			<description><![CDATA[<p>Le support de PHP4 est désormais arrêté avec la publication aujourd'hui de sa dernière version, la 4.4.8.</p>

<p>Cette nouvelle version, qui parait près de 8 mois après la précédente version, n'apporte pas de corrections majeures (corrections de bugs divers). A compter de ce jour, et ce jusqu'au 8 août 2008, seules des mises à jour de sécurité seront faites.</p>

<p>Source: PHP.net</p>

<hr /><a href="http://res.feedsportal.com/viral/bookmark_fr.cfm?link=http%3A%2F%2Fwww.ab-d.fr%2Fdate%2F2008-01-03%2F&title=PHP+4+s%27arr%C3%AAte+%21+Point+final+pr%C3%A9vu+pour+le+8%2F8%2F8"><img src="http://www.ab-d.fr/images/bookmark.gif" border="0" /></a><br /><br />]]></description>
			<comments>http://www.ab-d.fr/tag/PHP/</comments>
			<guid isPermaLink="false">http://www.ab-d.fr/date/2008-01-03/</guid>
		</item>

		<item>
			<title>Fonction PHP count() en JavaScript (prototype, function)</title>
			<link>http://www.ab-d.fr/date/2007-12-08/</link>
			<pubDate>Sat, 08 Dec 2007 00:00:00 +0100</pubDate>
			<author>noreply@ab-d.fr ( Benoit Asselin )</author>
			<category><![CDATA[Javascript]]></category>
			<category><![CDATA[PHP]]></category>
			<description><![CDATA[<pre>
Array.prototype.count = function() {
	return this.length;
}
</pre>
<p>Exemples</p>
<pre>
var v_array = [ 5, 10, 15, 20, 25];
document.writeln(v_array.count());  // 5
</pre>
<hr /><a href="http://res.feedsportal.com/viral/bookmark_fr.cfm?link=http%3A%2F%2Fwww.ab-d.fr%2Fdate%2F2007-12-08%2F&title=Fonction+PHP+count%28%29+en+JavaScript+%28prototype%2C+function%29"><img src="http://www.ab-d.fr/images/bookmark.gif" border="0" /></a><br /><br />]]></description>
			<comments>http://www.ab-d.fr/tag/PHP/</comments>
			<guid isPermaLink="false">http://www.ab-d.fr/date/2007-12-08/</guid>
		</item>

		<item>
			<title>Comment supprimer les problèmes UTF-8 avec MySQL et PHP ?</title>
			<link>http://www.ab-d.fr/date/2007-11-23/</link>
			<pubDate>Fri, 23 Nov 2007 00:00:00 +0100</pubDate>
			<author>noreply@ab-d.fr ( Benoit Asselin )</author>
			<category><![CDATA[MySQL]]></category>
			<category><![CDATA[UTF-8]]></category>
			<category><![CDATA[PHP]]></category>
			<description><![CDATA[<p>Il faut spécifier dans les scripts PHP que les données transmises sont en UTF-8.</p>
<pre>
...

// avec MySQLi
mysqli_query($link, "SET NAMES 'utf8' ");

// ancienne méthode
mysql_query("SET NAMES 'utf8' ");

...
</pre>
<hr /><a href="http://res.feedsportal.com/viral/bookmark_fr.cfm?link=http%3A%2F%2Fwww.ab-d.fr%2Fdate%2F2007-11-23%2F&title=Comment+supprimer+les+probl%C3%A8mes+UTF-8+avec+MySQL+et+PHP+%3F"><img src="http://www.ab-d.fr/images/bookmark.gif" border="0" /></a><br /><br />]]></description>
			<comments>http://www.ab-d.fr/tag/PHP/</comments>
			<guid isPermaLink="false">http://www.ab-d.fr/date/2007-11-23/</guid>
		</item>

		<item>
			<title>Comment écrire une variable PHP avec des accents ou des espaces ?</title>
			<link>http://www.ab-d.fr/date/2007-10-22/</link>
			<pubDate>Mon, 22 Oct 2007 00:00:00 +0100</pubDate>
			<author>noreply@ab-d.fr ( Benoit Asselin )</author>
			<category><![CDATA[PHP]]></category>
			<description><![CDATA[<pre>
&lt;?php

${'Variable Texte'} = 'Ceci est une Variable Texte.';

echo ${'Variable Texte'};

?&gt;
</pre>
<hr /><a href="http://res.feedsportal.com/viral/bookmark_fr.cfm?link=http%3A%2F%2Fwww.ab-d.fr%2Fdate%2F2007-10-22%2F&title=Comment+%C3%A9crire+une+variable+PHP+avec+des+accents+ou+des+espaces+%3F"><img src="http://www.ab-d.fr/images/bookmark.gif" border="0" /></a><br /><br />]]></description>
			<comments>http://www.ab-d.fr/tag/PHP/</comments>
			<guid isPermaLink="false">http://www.ab-d.fr/date/2007-10-22/</guid>
		</item>

		<item>
			<title>Fonction PHP in_array() en JavaScript (prototype, function, inarray)</title>
			<link>http://www.ab-d.fr/date/2007-10-14/</link>
			<pubDate>Sun, 14 Oct 2007 00:00:00 +0100</pubDate>
			<author>noreply@ab-d.fr ( Benoit Asselin )</author>
			<category><![CDATA[Javascript]]></category>
			<category><![CDATA[PHP]]></category>
			<description><![CDATA[<pre>
Array.prototype.in_array = function(p_val) {
	for(var i = 0, l = this.length; i &lt; l; i++) {
		if(this[i] == p_val) {
			return true;
		}
	}
	return false;
}
</pre>
<p>Exemples</p>
<pre>
var v_array = [ 5, 10, 15, 20, 25];
document.writeln(v_array.in_array(10));  // true
document.writeln(v_array.in_array(11));  // false
</pre>
<hr /><a href="http://res.feedsportal.com/viral/bookmark_fr.cfm?link=http%3A%2F%2Fwww.ab-d.fr%2Fdate%2F2007-10-14%2F&title=Fonction+PHP+in_array%28%29+en+JavaScript+%28prototype%2C+function%2C+inarray%29"><img src="http://www.ab-d.fr/images/bookmark.gif" border="0" /></a><br /><br />]]></description>
			<comments>http://www.ab-d.fr/tag/PHP/</comments>
			<guid isPermaLink="false">http://www.ab-d.fr/date/2007-10-14/</guid>
		</item>

	</channel>
</rss>
