<?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>Ayuda con tus Tareas &#187; php</title>
	<atom:link href="http://ayuda.fotopex.com/category/programacion/php/feed/" rel="self" type="application/rss+xml" />
	<link>http://ayuda.fotopex.com</link>
	<description>En forma fácil</description>
	<lastBuildDate>Sat, 04 Sep 2010 16:22:03 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.1-alpha</generator>
		<item>
		<title>Fechas en PHP de Manera Fácil</title>
		<link>http://ayuda.fotopex.com/programacion/php/fechas-en-php-de-manera-facil/</link>
		<comments>http://ayuda.fotopex.com/programacion/php/fechas-en-php-de-manera-facil/#comments</comments>
		<pubDate>Sat, 04 Sep 2010 16:21:26 +0000</pubDate>
		<dc:creator>Mr. FotoPex</dc:creator>
				<category><![CDATA[php]]></category>
		<category><![CDATA[Date]]></category>
		<category><![CDATA[Fechas]]></category>
		<category><![CDATA[Time]]></category>

		<guid isPermaLink="false">http://ayuda.fotopex.com/?p=797</guid>
		<description><![CDATA[Algo que es muy común pero también un poco complicado son las fechas en php, para que entiendas bien como utilizarlas te dejo unas funciones que te ayudaran. Lo básico, vamos a ver las tres funciones en PHP que harán la mayoría del trabajo en la manipulación de fechas. time(): devuelve la fecha y hora [...]]]></description>
			<content:encoded><![CDATA[<div style="padding: 5px; float: right; " >
 <script type="text/javascript"><!--
google_ad_client = "pub-6087605660472467";
/* ayuda-foto-adsense-cuadro300x250, creado 4/12/08 */ 
google_ad_slot = "1220677556";
google_ad_width = 300;
google_ad_height = 250;
//-->
</script>
<script type="text/javascript"
src="http://pagead2.googlesyndication.com/pagead/show_ads.js">
</script>
</div>
<p>Algo que es muy común pero también un poco complicado son las fechas en php, para que entiendas bien como utilizarlas te dejo unas funciones que te ayudaran.</p>
<p>Lo básico, vamos a ver las tres funciones en PHP que harán la mayoría del trabajo en la manipulación de fechas.</p>
<p><strong>time()</strong>: devuelve la fecha y hora actual expresada en segundos (desde el 1 de enero de 1970 - llamada timestamp). Se puede utilizar para sumar o restar fechas así como guardarla en base de datos.<br />
<strong>date()</strong>: devuelve la fecha de acuerdo al formato que definamos sirve para imprimir las fechas en formatos legibles.<br />
<strong>strtotime()</strong>: convierte una texto en fecha expresada en timestamp.</p>
<p>Entonces, resumiendo la <strong>time()</strong> devolverá la fecha para poder manipularla posteriormente <strong>date()</strong> dará formato legible para los usuarios.</p>
<p><strong>Como usar la función time</strong>:<br />
<span id="more-797"></span></p>
<div class="igBar"><span id="lphp-3"><a href="#" onclick="javascript:showPlainTxt('php-3'); return false;">Texto Plano</a></span></div>
<div class="syntax_hilite"><span class="langName">PHP:</span>
<div id="php-3">
<div class="php">
<ol>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<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-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#FF9933; font-style:italic;">// imprimir la hora actual</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><a href="http://www.php.net/echo" target="_blank"><span style="color:#000066;">echo</span></a> <a href="http://www.php.net/time" target="_blank"><span style="color:#000066;">time</span></a><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#006600; font-weight:bold;">&#41;</span>; <span style="color:#FF9933; font-style:italic;">// 1270966374</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#FF9933; font-style:italic;">// imprimir dos horas antes de la hora actual</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><a href="http://www.php.net/echo" target="_blank"><span style="color:#000066;">echo</span></a> <span style="color:#006600; font-weight:bold;">&#40;</span><a href="http://www.php.net/time" target="_blank"><span style="color:#000066;">time</span></a><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#006600; font-weight:bold;">&#41;</span>-<span style="color:#CC66CC;color:#800000;">2</span>*<span style="color:#CC66CC;color:#800000;">60</span>*<span style="color:#CC66CC;color:#800000;">60</span><span style="color:#006600; font-weight:bold;">&#41;</span>; <span style="color:#FF9933; font-style:italic;">// 1270959174</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#FF9933; font-style:italic;">// imprimir la fecha de hace una semana</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><a href="http://www.php.net/echo" target="_blank"><span style="color:#000066;">echo</span></a> <span style="color:#006600; font-weight:bold;">&#40;</span><a href="http://www.php.net/time" target="_blank"><span style="color:#000066;">time</span></a><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#006600; font-weight:bold;">&#41;</span>-<span style="color:#CC66CC;color:#800000;">7</span>*<span style="color:#CC66CC;color:#800000;">24</span>*<span style="color:#CC66CC;color:#800000;">60</span>*<span style="color:#CC66CC;color:#800000;">60</span><span style="color:#006600; font-weight:bold;">&#41;</span>; <span style="color:#FF9933; font-style:italic;">// 1270361574 </span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><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;color:#3A6A8B;">
<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-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#0000FF;">$semana_sig</span> = <a href="http://www.php.net/time" target="_blank"><span style="color:#000066;">time</span></a><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#006600; font-weight:bold;">&#41;</span> + <span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#CC66CC;color:#800000;">7</span> * <span style="color:#CC66CC;color:#800000;">24</span> * <span style="color:#CC66CC;color:#800000;">60</span> * <span style="color:#CC66CC;color:#800000;">60</span><span style="color:#006600; font-weight:bold;">&#41;</span>;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span style="color:#FF9933; font-style:italic;">// 7 días; 24 horas; 60 minutos; 60 segundos</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><a href="http://www.php.net/echo" target="_blank"><span style="color:#000066;">echo</span></a> <span style="color:#FF0000;">'Ahora:&nbsp; &nbsp; &nbsp; &nbsp;'</span>. <a href="http://www.php.net/date" target="_blank"><span style="color:#000066;">date</span></a><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#FF0000;">'Y-m-d'</span><span style="color:#006600; font-weight:bold;">&#41;</span> .<span style="color:#FF0000;">"<span style="color:#000099; font-weight:bold;">\n</span>"</span>;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><a href="http://www.php.net/echo" target="_blank"><span style="color:#000066;">echo</span></a> <span style="color:#FF0000;">'Semana Siguiente: '</span>. <a href="http://www.php.net/date" target="_blank"><span style="color:#000066;">date</span></a><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#FF0000;">'Y-m-d'</span>, <span style="color:#0000FF;">$semana_sig</span><span style="color:#006600; font-weight:bold;">&#41;</span> .<span style="color:#FF0000;">"<span style="color:#000099; font-weight:bold;">\n</span>"</span>;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#FF9933; font-style:italic;">// o usar strtotime():</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><a href="http://www.php.net/echo" target="_blank"><span style="color:#000066;">echo</span></a> <span style="color:#FF0000;">'Semana Siguiente: '</span>. <a href="http://www.php.net/date" target="_blank"><span style="color:#000066;">date</span></a><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#FF0000;">'Y-m-d'</span>, <a href="http://www.php.net/strtotime" target="_blank"><span style="color:#000066;">strtotime</span></a><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#FF0000;">'+1 week'</span><span style="color:#006600; font-weight:bold;">&#41;</span><span style="color:#006600; font-weight:bold;">&#41;</span> .<span style="color:#FF0000;">"<span style="color:#000099; font-weight:bold;">\n</span>"</span>;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><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;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">El resultado sería algo similar a:</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">Ahora:&nbsp; &nbsp; &nbsp; &nbsp; <span style="color:#CC66CC;color:#800000;">2010</span>-<span style="color:#CC66CC;color:#800000;">03</span>-<span style="color:#CC66CC;color:#800000;">30</span> </div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">Semana Siguiente: <span style="color:#CC66CC;color:#800000;">2010</span>-<span style="color:#CC66CC;color:#800000;">04</span>-<span style="color:#CC66CC;color:#800000;">06</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">Semana Siguiente: <span style="color:#CC66CC;color:#800000;">2010</span>-<span style="color:#CC66CC;color:#800000;">04</span>-<span style="color:#CC66CC;color:#800000;">06</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">Restando fechas</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<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-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#0000FF;">$transc</span> = <a href="http://www.php.net/strtotime" target="_blank"><span style="color:#000066;">strtotime</span></a><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#FF0000;">'2010-09-02'</span><span style="color:#006600; font-weight:bold;">&#41;</span> - <a href="http://www.php.net/strtotime" target="_blank"><span style="color:#000066;">strtotime</span></a><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#FF0000;">'2010-09-01'</span><span style="color:#006600; font-weight:bold;">&#41;</span>;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><a href="http://www.php.net/echo" target="_blank"><span style="color:#000066;">echo</span></a> <span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#0000FF;">$transc</span> /<span style="color:#CC66CC;color:#800000;">24</span>*<span style="color:#CC66CC;color:#800000;">60</span>*<span style="color:#CC66CC;color:#800000;">60</span><span style="color:#006600; font-weight:bold;">&#41;</span>;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<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>
</div>
<p></p>
<p><strong>Como utilizar la función date</strong>:</p>
<div class="igBar"><span id="lphp-4"><a href="#" onclick="javascript:showPlainTxt('php-4'); return false;">Texto Plano</a></span></div>
<div class="syntax_hilite"><span class="langName">PHP:</span>
<div id="php-4">
<div class="php">
<ol>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<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-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#FF9933; font-style:italic;">// imprimir la fecha actual</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><a href="http://www.php.net/echo" target="_blank"><span style="color:#000066;">echo</span></a> <a href="http://www.php.net/date" target="_blank"><span style="color:#000066;">date</span></a><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#FF0000;">"d/m/Y"</span><span style="color:#006600; font-weight:bold;">&#41;</span>; <span style="color:#FF9933; font-style:italic;">// 10/04/2010</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#FF9933; font-style:italic;">// imprimir la hora actual</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><a href="http://www.php.net/echo" target="_blank"><span style="color:#000066;">echo</span></a> <a href="http://www.php.net/date" target="_blank"><span style="color:#000066;">date</span></a><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#FF0000;">"h:m:s a"</span><span style="color:#006600; font-weight:bold;">&#41;</span>; <span style="color:#FF9933; font-style:italic;">// 10:04:52 pm</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#FF9933; font-style:italic;">// imprimir dos horas antes de la hora actual</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><a href="http://www.php.net/echo" target="_blank"><span style="color:#000066;">echo</span></a> <a href="http://www.php.net/date" target="_blank"><span style="color:#000066;">date</span></a><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#FF0000;">"h:m:s a"</span>, <a href="http://www.php.net/time" target="_blank"><span style="color:#000066;">time</span></a><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#006600; font-weight:bold;">&#41;</span>-<span style="color:#CC66CC;color:#800000;">2</span>*<span style="color:#CC66CC;color:#800000;">60</span>*<span style="color:#CC66CC;color:#800000;">60</span><span style="color:#006600; font-weight:bold;">&#41;</span>; <span style="color:#FF9933; font-style:italic;">// 08:04:52 pm ?&gt;</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<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;color:#3A6A8B;">
<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-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#FF9933; font-style:italic;">// Asumir que hoy es March 10th, 2001, 5:16:18 pm</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#0000FF;">$today</span> = <a href="http://www.php.net/date" target="_blank"><span style="color:#000066;">date</span></a><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#FF0000;">"F j, Y, g:i a"</span><span style="color:#006600; font-weight:bold;">&#41;</span>;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span style="color:#FF9933; font-style:italic;">// March 10, 2001, 5:16 pm</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#0000FF;">$today</span> = <a href="http://www.php.net/date" target="_blank"><span style="color:#000066;">date</span></a><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#FF0000;">"m.d.y"</span><span style="color:#006600; font-weight:bold;">&#41;</span>;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span style="color:#FF9933; font-style:italic;">// 03.10.01</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#0000FF;">$today</span> = <a href="http://www.php.net/date" target="_blank"><span style="color:#000066;">date</span></a><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#FF0000;">"j, n, Y"</span><span style="color:#006600; font-weight:bold;">&#41;</span>;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span style="color:#FF9933; font-style:italic;">// 10, 3, 2001</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#0000FF;">$today</span> = <a href="http://www.php.net/date" target="_blank"><span style="color:#000066;">date</span></a><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#FF0000;">"Ymd"</span><span style="color:#006600; font-weight:bold;">&#41;</span>;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span style="color:#FF9933; font-style:italic;">// 20010310</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#0000FF;">$today</span> = <a href="http://www.php.net/date" target="_blank"><span style="color:#000066;">date</span></a><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#FF0000;">'h-i-s, j-m-y, it is w Day'</span><span style="color:#006600; font-weight:bold;">&#41;</span>;&nbsp; &nbsp; &nbsp;<span style="color:#FF9933; font-style:italic;">// 05-16-18, 10-03-01, 1631 1618 6 Satpm01</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#0000FF;">$today</span> = <a href="http://www.php.net/date" target="_blank"><span style="color:#000066;">date</span></a><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#FF0000;">'<span style="color:#000099; font-weight:bold;">\i</span><span style="color:#000099; font-weight:bold;">\t</span> <span style="color:#000099; font-weight:bold;">\i</span><span style="color:#000099; font-weight:bold;">\s</span> <span style="color:#000099; font-weight:bold;">\t</span><span style="color:#000099; font-weight:bold;">\h</span><span style="color:#000099; font-weight:bold;">\e</span> jS <span style="color:#000099; font-weight:bold;">\d</span><span style="color:#000099; font-weight:bold;">\a</span><span style="color:#000099; font-weight:bold;">\y</span>.'</span><span style="color:#006600; font-weight:bold;">&#41;</span>;&nbsp; &nbsp;<span style="color:#FF9933; font-style:italic;">// it is the 10th day.</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#0000FF;">$today</span> = <a href="http://www.php.net/date" target="_blank"><span style="color:#000066;">date</span></a><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#FF0000;">"D M j G:i:s T Y"</span><span style="color:#006600; font-weight:bold;">&#41;</span>;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span style="color:#FF9933; font-style:italic;">// Sat Mar 10 17:16:18 MST 2001</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#0000FF;">$today</span> = <a href="http://www.php.net/date" target="_blank"><span style="color:#000066;">date</span></a><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#FF0000;">'H:m:s <span style="color:#000099; font-weight:bold;">\m</span> <span style="color:#000099; font-weight:bold;">\i</span><span style="color:#000099; font-weight:bold;">\s</span><span style="color:#000099; font-weight:bold;">\ </span><span style="color:#000099; font-weight:bold;">\m</span><span style="color:#000099; font-weight:bold;">\o</span><span style="color:#000099; font-weight:bold;">\n</span><span style="color:#000099; font-weight:bold;">\t</span><span style="color:#000099; font-weight:bold;">\h</span>'</span><span style="color:#006600; font-weight:bold;">&#41;</span>;&nbsp; &nbsp; &nbsp;<span style="color:#FF9933; font-style:italic;">// 17:03:18 m is month</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#0000FF;">$today</span> = <a href="http://www.php.net/date" target="_blank"><span style="color:#000066;">date</span></a><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#FF0000;">"H:i:s"</span><span style="color:#006600; font-weight:bold;">&#41;</span>;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span style="color:#FF9933; font-style:italic;">// 17:16:18</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#000000; font-weight:bold;">?&gt;</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<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;color:#3A6A8B;">
<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-weight: bold;color:#26536A;">
<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;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#0000FF;">$hour</span> = <a href="http://www.php.net/date" target="_blank"><span style="color:#000066;">date</span></a><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#FF0000;">"H"</span><span style="color:#006600; font-weight:bold;">&#41;</span>;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#0000FF;">$minute</span> = <a href="http://www.php.net/date" target="_blank"><span style="color:#000066;">date</span></a><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#FF0000;">"i"</span><span style="color:#006600; font-weight:bold;">&#41;</span>;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#0000FF;">$second</span> = <a href="http://www.php.net/date" target="_blank"><span style="color:#000066;">date</span></a><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#FF0000;">"s"</span><span style="color:#006600; font-weight:bold;">&#41;</span>; </div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#0000FF;">$month</span> = <a href="http://www.php.net/date" target="_blank"><span style="color:#000066;">date</span></a><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#FF0000;">"n"</span><span style="color:#006600; font-weight:bold;">&#41;</span>;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#0000FF;">$day</span> = <a href="http://www.php.net/date" target="_blank"><span style="color:#000066;">date</span></a><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#FF0000;">"j"</span><span style="color:#006600; font-weight:bold;">&#41;</span>;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#0000FF;">$year</span> = <a href="http://www.php.net/date" target="_blank"><span style="color:#000066;">date</span></a><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#FF0000;">"Y"</span><span style="color:#006600; font-weight:bold;">&#41;</span>;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#0000FF;">$ahorita</span> = <a href="http://www.php.net/date" target="_blank"><span style="color:#000066;">date</span></a><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#FF0000;">'Y-m-d H:i:s'</span>, <a href="http://www.php.net/mktime" target="_blank"><span style="color:#000066;">mktime</span></a><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#0000FF;">$hour</span>, <span style="color:#0000FF;">$minute</span>, <span style="color:#0000FF;">$second</span>, <span style="color:#0000FF;">$month</span>, <span style="color:#0000FF;">$day</span>, <span style="color:#0000FF;">$year</span><span style="color:#006600; font-weight:bold;">&#41;</span><span style="color:#006600; font-weight:bold;">&#41;</span>;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#FF9933; font-style:italic;">// 2010-05-13 06:06:27</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<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>
</div>
<p></p>
<p>El <strong>timezone</strong> o<strong> zona horaria</strong> es la hora de cada localidad de acuerdo a su ubicación en la tierra respecto a una hora universal. Pueden conocer el timezone de su localidad en <a href="http://www.worldtimezone.com/" target="_blank">World Time Zone</a>, por ejemplo si estamos en Oaxaca- México, el timezone es -6.</p>
<p>Cuando imprimimos una fecha utilizando directamente la función date(), esta lo hará pero basado en la zona horaria de mi proveedor de hosting. Para corregir esto es necesario hacer un ajuste de acuerdo al timezone nuestro y de nuestro servidor de hosting.</p>
<p>Para corregir este detalle de la <strong>Zona Horaria</strong> utilizamos la instrucción:<br />
<strong>date_default_timezone_set</strong> —  Establece la zona horaria predeterminada usada por todas las funciones de fecha/hora en un script.</p>
<p>Ejemplo:<br />
<strong>date_default_timezone_set('America/Mexico_City');</strong></p>
<p>Aquí te dejo una lista para identificar tu zona horaria.</p>
<p>Kwajalein = -12.00,<br />
Pacific/Midway = -11.00,<br />
Pacific/Honolulu = -10.00,<br />
America/Anchorage = -9.00,<br />
America/Los_Angeles = -8.00,<br />
America/Denver = -7.00,<br />
America/Tegucigalpa = -6.00,<br />
America/New_York = -5.00,<br />
America/Caracas = -4.30,<br />
America/Halifax = -4.00,<br />
America/St_Johns = -3.30,<br />
America/Argentina/Buenos_Aires = -3.00,<br />
America/Sao_Paulo = -3.00,<br />
Atlantic/South_Georgia = -2.00,<br />
Atlantic/Azores = -1.00,<br />
Europe/Dublin = 0,<br />
Europe/Belgrade = 1.00,<br />
Europe/Minsk = 2.00,<br />
Asia/Kuwait = 3.00,<br />
Asia/Tehran = 3.30,<br />
Asia/Muscat = 4.00,<br />
Asia/Yekaterinburg = 5.00,<br />
Asia/Kolkata = 5.30,<br />
Asia/Katmandu = 5.45,<br />
Asia/Dhaka = 6.00,<br />
Asia/Rangoon = 6.30,<br />
Asia/Krasnoyarsk = 7.00,<br />
Asia/Brunei = 8.00,<br />
Asia/Seoul = 9.00,<br />
Australia/Darwin = 9.30,<br />
Australia/Canberra = 10.00,<br />
Asia/Magadan = 11.00,<br />
Pacific/Fiji = 12.00,<br />
Pacific/Tongatapu = 13.00</p>
]]></content:encoded>
			<wfw:commentRss>http://ayuda.fotopex.com/programacion/php/fechas-en-php-de-manera-facil/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Cómo Cerrar Una Sesión Por Cierre Del Navegador</title>
		<link>http://ayuda.fotopex.com/programacion/php/como-cerrar-una-sesion-por-cierre-del-navegador/</link>
		<comments>http://ayuda.fotopex.com/programacion/php/como-cerrar-una-sesion-por-cierre-del-navegador/#comments</comments>
		<pubDate>Fri, 03 Sep 2010 15:24:36 +0000</pubDate>
		<dc:creator>Mr. FotoPex</dc:creator>
				<category><![CDATA[php]]></category>
		<category><![CDATA[Navegador]]></category>
		<category><![CDATA[script]]></category>
		<category><![CDATA[sesiones]]></category>

		<guid isPermaLink="false">http://ayuda.fotopex.com/?p=802</guid>
		<description><![CDATA[Como primer paso vamos a forzar al php.ini a que propague la sesión solamente en cookies y por otro lado, asignarle a ésta, una duración cero. Podemos hacerlo de dos formas: Opción 1: Configurar el archivo de inicio de php (php.ini) en forma directa. Si tienes acceso a este archivo, habrá que buscar y cambiar [...]]]></description>
			<content:encoded><![CDATA[<div style="padding: 5px; float: right; " >
 <script type="text/javascript"><!--
google_ad_client = "pub-6087605660472467";
/* ayuda-foto-adsense-cuadro300x250, creado 4/12/08 */ 
google_ad_slot = "1220677556";
google_ad_width = 300;
google_ad_height = 250;
//-->
</script>
<script type="text/javascript"
src="http://pagead2.googlesyndication.com/pagead/show_ads.js">
</script>
</div>
<p>Como primer paso vamos a forzar al php.ini a que propague la sesión solamente en cookies y por otro lado, asignarle a ésta, una duración cero. </p>
<p>Podemos hacerlo de dos formas:</p>
<p><strong>Opción 1</strong>:</p>
<p>Configurar el archivo de inicio de php (php.ini) en forma directa. Si tienes acceso a este archivo, habrá que buscar y cambiar el valor a:<br />
<strong>session.use_trans_sid = 0</strong><br />
<strong>session.use_only_cookies = 1</strong></p>
<p>Esta última, justamente será la que indicará que la sesión debe propagarse solo a través de cookies.</p>
<p><strong>Opción 2</strong>:</p>
<p>Cambiar la configuración del php.ini desde nuestro script php.</p>
<p>Consiste en forzar al php.ini desde nuestro script php (No todos los servidores tienen habilitada esta opción. Si el servidor no es propio, por las dudas, consulta con tu proveedor).</p>
<p>Para hacerlo, utilizaremos la función ini_set()</p>
<p><strong>ini_set("session.use_trans_sid","0");</strong><br />
<strong>ini_set("session.use_only_cookies","1");</strong></p>
<p>Ahora vamos a cambiar el parámetro de duración a la cookie de la sesión. Esto lo haremos en nuestro script con la siguiente instrucción:</p>
<p><strong>session_set_cookie_params(0, "/", $HTTP_SERVER_VARS["HTTP_HOST"], 0);</strong><br />
Estamos indicando una duración de 0 (cero) segundos.</p>
]]></content:encoded>
			<wfw:commentRss>http://ayuda.fotopex.com/programacion/php/como-cerrar-una-sesion-por-cierre-del-navegador/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Cómo Cerrar Una Sesión Por Inactividad</title>
		<link>http://ayuda.fotopex.com/programacion/php/como-cerrar-una-sesion-por-inactividad/</link>
		<comments>http://ayuda.fotopex.com/programacion/php/como-cerrar-una-sesion-por-inactividad/#comments</comments>
		<pubDate>Fri, 03 Sep 2010 14:57:28 +0000</pubDate>
		<dc:creator>Mr. FotoPex</dc:creator>
				<category><![CDATA[php]]></category>
		<category><![CDATA[caducar]]></category>
		<category><![CDATA[expira]]></category>
		<category><![CDATA[sesiones]]></category>
		<category><![CDATA[tiempo]]></category>

		<guid isPermaLink="false">http://ayuda.fotopex.com/?p=800</guid>
		<description><![CDATA[Si ya conoces el sesiones en php, y necesitas terminar una sesión por inactividad este es un ejemplo muy fácil de seguir. No debes de olvidar que siempre debes iniciar tus archivos con la instrucción: Texto Plano PHP: &#60;?php session_start&#40;&#41;; ?&#62; En el archivo de validar_usuario (del ejemplo como hacer login) debemos asignar un valor [...]]]></description>
			<content:encoded><![CDATA[<p>Si ya conoces el <a href="http://ayuda.fotopex.com/programacion/php/sesiones-en-php/">sesiones en php</a>, y necesitas terminar una sesión por inactividad este es un ejemplo muy fácil de seguir.</p>
<p>No debes de olvidar que siempre debes iniciar tus archivos con la instrucción:</p>
<div class="igBar"><span id="lphp-9"><a href="#" onclick="javascript:showPlainTxt('php-9'); return false;">Texto Plano</a></span></div>
<div class="syntax_hilite"><span class="langName">PHP:</span>
<div id="php-9">
<div class="php">
<ol>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#000000; font-weight:bold;">&lt;?php</span> <a href="http://www.php.net/session_start" target="_blank"><span style="color:#000066;">session_start</span></a><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#006600; font-weight:bold;">&#41;</span>; <span style="color:#000000; font-weight:bold;">?&gt;</span> </div>
</li>
</ol>
</div>
</div>
</div>
<p></p>
<p>En el archivo de <a href="http://ayuda.fotopex.com/programacion/php/hacer-login-de-usuarios-con-php-y-mysql/">validar_usuario</a> (del ejemplo como hacer login) debemos asignar un valor nuevo al arreglo de la sesión.</p>
<div class="igBar"><span id="lphp-10"><a href="#" onclick="javascript:showPlainTxt('php-10'); return false;">Texto Plano</a></span></div>
<div class="syntax_hilite"><span class="langName">PHP:</span>
<div id="php-10">
<div class="php">
<ol>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#000000; font-weight:bold;">&lt;?php</span> <span style="color:#0000FF;">$_SESSION</span><span style="color:#006600; font-weight:bold;">&#91;</span><span style="color:#FF0000;">"ultimoAcceso"</span><span style="color:#006600; font-weight:bold;">&#93;</span>= <a href="http://www.php.net/date" target="_blank"><span style="color:#000066;">date</span></a><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#FF0000;">"Y-n-j H:i:s"</span><span style="color:#006600; font-weight:bold;">&#41;</span>;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color:#FF9933; font-style:italic;">//defino la fecha y hora de inicio de sesión en formato aaaa-mm-dd hh:mm:ss ?&gt; </span></div>
</li>
</ol>
</div>
</div>
</div>
<p></p>
<p>Ahora podemos calculamos el tiempo transcurrido en nuestros archivos.<br />
<span id="more-800"></span></p>
<p>
 <script type="text/javascript"><!--
google_ad_client = "pub-6087605660472467";
/* ayuda-foto-adsense-cuadro300x250, creado 4/12/08 */ 
google_ad_slot = "1220677556";
google_ad_width = 300;
google_ad_height = 250;
//-->
</script>
<script type="text/javascript"
src="http://pagead2.googlesyndication.com/pagead/show_ads.js">
</script>
</p>
<div class="igBar"><span id="lphp-11"><a href="#" onclick="javascript:showPlainTxt('php-11'); return false;">Texto Plano</a></span></div>
<div class="syntax_hilite"><span class="langName">PHP:</span>
<div id="php-11">
<div class="php">
<ol>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<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-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color:#0000FF;">$fechaOld</span>= <span style="color:#0000FF;">$_SESSION</span><span style="color:#006600; font-weight:bold;">&#91;</span><span style="color:#FF0000;">"ultimoAcceso"</span><span style="color:#006600; font-weight:bold;">&#93;</span>;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color:#0000FF;">$ahora</span> = <a href="http://www.php.net/date" target="_blank"><span style="color:#000066;">date</span></a><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#FF0000;">"Y-n-j H:i:s"</span><span style="color:#006600; font-weight:bold;">&#41;</span>;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color:#0000FF;">$tiempo_transcurrido</span> = <span style="color:#006600; font-weight:bold;">&#40;</span><a href="http://www.php.net/strtotime" target="_blank"><span style="color:#000066;">strtotime</span></a><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#0000FF;">$ahora</span><span style="color:#006600; font-weight:bold;">&#41;</span>-<a href="http://www.php.net/strtotime" target="_blank"><span style="color:#000066;">strtotime</span></a><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#0000FF;">$fechaOld</span><span style="color:#006600; font-weight:bold;">&#41;</span><span style="color:#006600; font-weight:bold;">&#41;</span>;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color:#616100;">if</span><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#0000FF;">$tiempo_transcurrido</span>&gt;= <span style="color:#CC66CC;color:#800000;">600</span><span style="color:#006600; font-weight:bold;">&#41;</span> <span style="color:#006600; font-weight:bold;">&#123;</span> <span style="color:#FF9933; font-style:italic;">//comparamos el tiempo y verificamos si pasaron 10 minutos o más</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; <a href="http://www.php.net/session_destroy" target="_blank"><span style="color:#000066;">session_destroy</span></a><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#006600; font-weight:bold;">&#41;</span>; <span style="color:#FF9933; font-style:italic;">// destruimos la sesión</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; <a href="http://www.php.net/header" target="_blank"><span style="color:#000066;">header</span></a><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#FF0000;">"Location: index.php"</span><span style="color:#006600; font-weight:bold;">&#41;</span>; <span style="color:#FF9933; font-style:italic;">//enviamos al usuario a la página principal</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color:#006600; font-weight:bold;">&#125;</span><span style="color:#616100;">else</span> <span style="color:#006600; font-weight:bold;">&#123;</span>&nbsp; &nbsp; &nbsp; &nbsp;<span style="color:#FF9933; font-style:italic;">//sino, actualizo la fecha de la sesión</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color:#0000FF;">$_SESSION</span><span style="color:#006600; font-weight:bold;">&#91;</span><span style="color:#FF0000;">"ultimoAcceso"</span><span style="color:#006600; font-weight:bold;">&#93;</span> = <span style="color:#0000FF;">$ahora</span>;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp;<span style="color:#006600; font-weight:bold;">&#125;</span> <span style="color:#000000; font-weight:bold;">?&gt;</span> </div>
</li>
</ol>
</div>
</div>
</div>
<p></p>
<p>Te recomiendo que hagas un archivo y después lo utilices con la instrucción <a href="http://ayuda.fotopex.com/programacion/php/include-y-require/">include</a>.</p>
<div class="igBar"><span id="lphp-12"><a href="#" onclick="javascript:showPlainTxt('php-12'); return false;">Texto Plano</a></span></div>
<div class="syntax_hilite"><span class="langName">PHP:</span>
<div id="php-12">
<div class="php">
<ol>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#000000; font-weight:bold;">&lt;?php</span> <span style="color:#616100;">include</span><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#FF0000;">"tuarchivo.htm"</span><span style="color:#006600; font-weight:bold;">&#41;</span>; <span style="color:#000000; font-weight:bold;">?&gt;</span> </div>
</li>
</ol>
</div>
</div>
</div>
<p></p>
<p>esta es una manera sencilla de cerrar la sesión por inactividad en php.<br />
¿Se te ocurre algo más?</p>
]]></content:encoded>
			<wfw:commentRss>http://ayuda.fotopex.com/programacion/php/como-cerrar-una-sesion-por-inactividad/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Cookies</title>
		<link>http://ayuda.fotopex.com/programacion/php/cookies/</link>
		<comments>http://ayuda.fotopex.com/programacion/php/cookies/#comments</comments>
		<pubDate>Fri, 03 Sep 2010 13:38:00 +0000</pubDate>
		<dc:creator>Mr. FotoPex</dc:creator>
				<category><![CDATA[php]]></category>
		<category><![CDATA[cookies]]></category>
		<category><![CDATA[sesiones]]></category>
		<category><![CDATA[tips]]></category>

		<guid isPermaLink="false">http://ayuda.fotopex.com/?p=795</guid>
		<description><![CDATA[Las Cookies son pequeñas porciones de información almacenadas en la máquina cliente mediante el navegador utilizado, que transfiere el servidor en la cabecera de los mensajes. Para que se puedan enviar, la máquina cliente debe tenerlas habilitadas en su navegador, sólo pueden ser textos, de tamaño máximo de 1K, además sólo son válidas desde el [...]]]></description>
			<content:encoded><![CDATA[<div style="padding: 5px; float: left; " >
 <script type="text/javascript"><!--
google_ad_client = "pub-6087605660472467";
/* ayuda-foto-adsense-cuadro300x250, creado 4/12/08 */ 
google_ad_slot = "1220677556";
google_ad_width = 300;
google_ad_height = 250;
//-->
</script>
<script type="text/javascript"
src="http://pagead2.googlesyndication.com/pagead/show_ads.js">
</script>
</div>
<p>Las Cookies son pequeñas porciones de información almacenadas en la máquina cliente mediante el navegador utilizado, que transfiere el servidor en la cabecera de los mensajes. Para que se puedan enviar, la máquina cliente debe tenerlas habilitadas en su navegador, sólo pueden ser textos, de tamaño máximo de 1K, además  sólo son válidas desde el servidor que las envió.</p>
<p>Las Cookies pueden ser utilizadas para agilizar algunos procesos de identificación del usuario, o para saber sus intereses, por ejemplo si un usuario entra en tu tienda on-line y suele visitar el catálogo de electrónica, podemos ofrecerle las ofertas de ese departamento. Podemos de esa forma identificar a este visitante a través de diferentes páginas de un mismo sitio e incluso durante visitas entre distintos días.</p>
<p>Las Cookies son compatibles con <span id="more-795"></span>las versiones PHP3 PHP4 y PHP5 y los argumentos son opcionales excepto el nombre:</p>
<ul>
<li><strong>Nombre</strong>. Nombre de la cookie. Si  creamos una cookie solamente con el nombre, en el cliente se eliminara  la cookie que exista con ese nombre. También podemos reemplazar  cualquier argumento con una cadena vacía ("").</li>
<li><strong>Value</strong>. Valor que almacenará la cookie en el cliente.</li>
<li><strong>Expire</strong>. El argumento expire es un  argumento entero que indica la hora en que se eliminara la cookie en el  formato de hora que devuelven las funciones UNIX time() y mktime().  Normalmente se usa time() + N. segundos de duración, para especificar la duración de una cookie.</li>
<li><strong>Path</strong>. Subdirectorio en donde tiene valor la cookie.</li>
<li><strong>Dominio</strong>. Dominio en donde tiene valor la cookie. Si ponemos como dominio www.fotopex.com la cookie no se transmite para fotopex.com, mientras que si ponemos fotopex.com la cookie se transmite tanto para fotopex.com como para www.fotopex.com</li>
<li><strong>Secure</strong>. El argumento secure indica que la cookie solo se transmitirá a través de una conexión segura HTTPS.</li>
</ul>
<p>En definitiva:</p>
<div class="igBar"><span id="lphp-19"><a href="#" onclick="javascript:showPlainTxt('php-19'); return false;">Texto Plano</a></span></div>
<div class="syntax_hilite"><span class="langName">PHP:</span>
<div id="php-19">
<div class="php">
<ol>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">int <a href="http://www.php.net/setcookie" target="_blank"><span style="color:#000066;">setcookie</span></a> <span style="color:#006600; font-weight:bold;">&#40;</span>string Nombre, string Valor, int Expire, string Path, string Dominio, int Secure<span style="color:#006600; font-weight:bold;">&#41;</span> </div>
</li>
</ol>
</div>
</div>
</div>
<p></p>
<p>En este ejemplo establecemos una cookie de nombre visitante que contiene el valor X, que dura 1 hora (3600 segundos) válida para todo el dominio <a href="http://fotopex.com">fotopex.com </a></p>
<div class="igBar"><span id="lphp-20"><a href="#" onclick="javascript:showPlainTxt('php-20'); return false;">Texto Plano</a></span></div>
<div class="syntax_hilite"><span class="langName">PHP:</span>
<div id="php-20">
<div class="php">
<ol>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#000000; font-weight:bold;">&lt;?php</span> <a href="http://www.php.net/setcookie" target="_blank"><span style="color:#000066;">setcookie</span></a><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#FF0000;">"visitante"</span>, <span style="color:#FF0000;">"X"</span>, <a href="http://www.php.net/time" target="_blank"><span style="color:#000066;">time</span></a><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#006600; font-weight:bold;">&#41;</span>+<span style="color:#CC66CC;color:#800000;">3600</span>,<span style="color:#FF0000;">"/"</span>,<span style="color:#FF0000;">"fotopex.com"</span><span style="color:#006600; font-weight:bold;">&#41;</span>; <span style="color:#000000; font-weight:bold;">?&gt;</span> </div>
</li>
</ol>
</div>
</div>
</div>
<p></p>
<p>En este ejemplo establecemos la cookie costumbres con el valor del titulo de la página, y cuya duración es una hora.</p>
<div class="igBar"><span id="lphp-21"><a href="#" onclick="javascript:showPlainTxt('php-21'); return false;">Texto Plano</a></span></div>
<div class="syntax_hilite"><span class="langName">PHP:</span>
<div id="php-21">
<div class="php">
<ol>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&lt;html&gt;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<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;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp;&lt;title&gt;Fotos&lt;/title&gt;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<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;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp;<a href="http://www.php.net/setcookie" target="_blank"><span style="color:#000066;">setcookie</span></a><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#FF0000;">"costumbres"</span>, <span style="color:#FF0000;">'Fotos'</span>, <a href="http://www.php.net/time" target="_blank"><span style="color:#000066;">time</span></a><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#006600; font-weight:bold;">&#41;</span>+<span style="color:#CC66CC;color:#800000;">3600</span>,<span style="color:#FF0000;">"/"</span>,<span style="color:#FF0000;">""</span><span style="color:#006600; font-weight:bold;">&#41;</span>;&nbsp; &nbsp; </div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><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;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&lt;/head&gt;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&lt;body&gt;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&lt;H1&gt;Ejemplo de uso de cookie&lt;/H1&gt;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&lt;/body&gt;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&lt;/html&gt; </div>
</li>
</ol>
</div>
</div>
</div>
<p></p>
<p>Ahora vamos a recuperar el valor de la cookie establecida anteriormente.</p>
<div class="igBar"><span id="lphp-22"><a href="#" onclick="javascript:showPlainTxt('php-22'); return false;">Texto Plano</a></span></div>
<div class="syntax_hilite"><span class="langName">PHP:</span>
<div id="php-22">
<div class="php">
<ol>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&lt;html&gt;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<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;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp;&lt;title&gt;Ejemplo de PHP&lt;/title&gt;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<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;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&lt;body&gt;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&lt;H1&gt;Ejemplo de uso de cookie&lt;/H1&gt;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">Se ha establecido la cookie de nombre &lt;b&gt;costumbres&lt;/b&gt; y su valor es: &lt;b&gt;&lt;? <a href="http://www.php.net/print" target="_blank"><span style="color:#000066;">print</span></a> <span style="color:#0000FF;">$_COOKIE</span><span style="color:#006600; font-weight:bold;">&#91;</span><span style="color:#FF0000;">'costumbres'</span><span style="color:#006600; font-weight:bold;">&#93;</span>; ?&gt;&lt;/b&gt;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&lt;/body&gt;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&lt;/html&gt; </div>
</li>
</ol>
</div>
</div>
</div>
<p></p>
<p>Otros ejemplos:</p>
<div class="igBar"><span id="lphp-23"><a href="#" onclick="javascript:showPlainTxt('php-23'); return false;">Texto Plano</a></span></div>
<div class="syntax_hilite"><span class="langName">PHP:</span>
<div id="php-23">
<div class="php">
<ol>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<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-weight: bold;color:#26536A;">
<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;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp;<span style="color:#FF9933; font-style:italic;">// Esta cookie dura una hora. 1 hora = 3600 segundos</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp;<a href="http://www.php.net/setcookie" target="_blank"><span style="color:#000066;">setcookie</span></a><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#FF0000;">"visitas"</span>, <span style="color:#FF0000;">"1"</span>, <a href="http://www.php.net/time" target="_blank"><span style="color:#000066;">time</span></a><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#006600; font-weight:bold;">&#41;</span> + <span style="color:#CC66CC;color:#800000;">3600</span><span style="color:#006600; font-weight:bold;">&#41;</span>;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp;<span style="color:#FF9933; font-style:italic;">// Esta cookie dura un dia. 24 h = 86400 segundos</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp;<a href="http://www.php.net/setcookie" target="_blank"><span style="color:#000066;">setcookie</span></a><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#FF0000;">"visitas"</span>, <span style="color:#FF0000;">"1"</span>, <a href="http://www.php.net/time" target="_blank"><span style="color:#000066;">time</span></a><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#006600; font-weight:bold;">&#41;</span> + <span style="color:#CC66CC;color:#800000;">86400</span><span style="color:#006600; font-weight:bold;">&#41;</span>;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<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;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp;<span style="color:#FF9933; font-style:italic;">// esta cookie dura una semana. </span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp;<a href="http://www.php.net/setcookie" target="_blank"><span style="color:#000066;">setcookie</span></a><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#FF0000;">"visitas"</span>, <span style="color:#FF0000;">"1"</span>, <a href="http://www.php.net/time" target="_blank"><span style="color:#000066;">time</span></a><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#006600; font-weight:bold;">&#41;</span> + <span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#CC66CC;color:#800000;">7</span> * <span style="color:#CC66CC;color:#800000;">86400</span><span style="color:#006600; font-weight:bold;">&#41;</span> <span style="color:#006600; font-weight:bold;">&#41;</span>;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp;<span style="color:#FF9933; font-style:italic;">// esta cookie dura un año. 1 año = 31536000 segundos</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <a href="http://www.php.net/setcookie" target="_blank"><span style="color:#000066;">setcookie</span></a><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#FF0000;">"visitas"</span>, <span style="color:#FF0000;">"1"</span>, <a href="http://www.php.net/time" target="_blank"><span style="color:#000066;">time</span></a><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#006600; font-weight:bold;">&#41;</span> + <span style="color:#CC66CC;color:#800000;">31536000</span><span style="color:#006600; font-weight:bold;">&#41;</span>;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<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>
</div>
<p></p>
<p>También puedes hacer arreglos utilizando una variante en el nombre:</p>
<div class="igBar"><span id="lphp-24"><a href="#" onclick="javascript:showPlainTxt('php-24'); return false;">Texto Plano</a></span></div>
<div class="syntax_hilite"><span class="langName">PHP:</span>
<div id="php-24">
<div class="php">
<ol>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<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-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#FF9933; font-style:italic;">// set the cookies</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><a href="http://www.php.net/setcookie" target="_blank"><span style="color:#000066;">setcookie</span></a><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#FF0000;">"cookie[tres]"</span>, <span style="color:#FF0000;">"cookietres"</span><span style="color:#006600; font-weight:bold;">&#41;</span>;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><a href="http://www.php.net/setcookie" target="_blank"><span style="color:#000066;">setcookie</span></a><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#FF0000;">"cookie[dos]"</span>, <span style="color:#FF0000;">"cookiedos"</span><span style="color:#006600; font-weight:bold;">&#41;</span>;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><a href="http://www.php.net/setcookie" target="_blank"><span style="color:#000066;">setcookie</span></a><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#FF0000;">"cookie[uno]"</span>, <span style="color:#FF0000;">"cookieuno"</span><span style="color:#006600; font-weight:bold;">&#41;</span>;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<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;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#FF9933; font-style:italic;">// Después de recargar la pagina imprime lo siguiente</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#616100;">if</span> <span style="color:#006600; font-weight:bold;">&#40;</span><a href="http://www.php.net/isset" target="_blank"><span style="color:#000066;">isset</span></a><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#0000FF;">$_COOKIE</span><span style="color:#006600; font-weight:bold;">&#91;</span><span style="color:#FF0000;">'cookie'</span><span style="color:#006600; font-weight:bold;">&#93;</span><span style="color:#006600; font-weight:bold;">&#41;</span><span style="color:#006600; font-weight:bold;">&#41;</span> <span style="color:#006600; font-weight:bold;">&#123;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color:#616100;">foreach</span> <span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#0000FF;">$_COOKIE</span><span style="color:#006600; font-weight:bold;">&#91;</span><span style="color:#FF0000;">'cookie'</span><span style="color:#006600; font-weight:bold;">&#93;</span> <span style="color:#616100;">as</span> <span style="color:#0000FF;">$name</span> =&gt; <span style="color:#0000FF;">$value</span><span style="color:#006600; font-weight:bold;">&#41;</span> <span style="color:#006600; font-weight:bold;">&#123;</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; <a href="http://www.php.net/echo" target="_blank"><span style="color:#000066;">echo</span></a> <span style="color:#FF0000;">"$name : $value &lt;br /&gt;<span style="color:#000099; font-weight:bold;">\n</span>"</span>;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color:#006600; font-weight:bold;">&#125;</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#006600; font-weight:bold;">&#125;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<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>
</div>
<p>
El resultado del ejemplo sería:</p>
<p>tres : cookietres<br />
dos : cookiedos<br />
uno : cookieuno</p>
]]></content:encoded>
			<wfw:commentRss>http://ayuda.fotopex.com/programacion/php/cookies/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Resaltar Palabras de una Búsqueda con PHP</title>
		<link>http://ayuda.fotopex.com/programacion/php/resaltar-palabras-de-una-busqueda-con-php/</link>
		<comments>http://ayuda.fotopex.com/programacion/php/resaltar-palabras-de-una-busqueda-con-php/#comments</comments>
		<pubDate>Wed, 11 Aug 2010 23:34:00 +0000</pubDate>
		<dc:creator>Mr. FotoPex</dc:creator>
				<category><![CDATA[php]]></category>
		<category><![CDATA[búsqueda]]></category>
		<category><![CDATA[palabra]]></category>
		<category><![CDATA[Resaltar]]></category>

		<guid isPermaLink="false">http://ayuda.fotopex.com/?p=786</guid>
		<description><![CDATA[Si necesitas resaltar determinadas palabras dentro de un texto. Por ejemplo al mostrar los resultados de una búsqueda, podemos resaltar los términos buscados con la siguiente función: Texto Plano PHP: function highlight&#40;$cadena, $arr_palabras&#41; &#123; &#160; &#160; if &#40;!is_array &#40;$arr_palabras&#41; &#124;&#124; empty &#40;$arr_palabras&#41; &#124;&#124; !is_string &#40;$cadena&#41;&#41; &#123; &#160; &#160; &#160; &#160; return false; &#160; &#160; &#125; [...]]]></description>
			<content:encoded><![CDATA[<div style="padding: 5px; float: left; " >
 <script type="text/javascript"><!--
google_ad_client = "pub-6087605660472467";
/* ayuda-foto-adsense-cuadro300x250, creado 4/12/08 */ 
google_ad_slot = "1220677556";
google_ad_width = 300;
google_ad_height = 250;
//-->
</script>
<script type="text/javascript"
src="http://pagead2.googlesyndication.com/pagead/show_ads.js">
</script>
</div>
<p>Si necesitas resaltar determinadas palabras dentro de un texto. Por ejemplo al mostrar los resultados de una búsqueda, podemos resaltar los términos buscados con la siguiente función:</p>
<div style="clear:both;"></div>
<div class="igBar"><span id="lphp-27"><a href="#" onclick="javascript:showPlainTxt('php-27'); return false;">Texto Plano</a></span></div>
<div class="syntax_hilite"><span class="langName">PHP:</span>
<div id="php-27">
<div class="php">
<ol>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#000000; font-weight:bold;">function</span> highlight<span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#0000FF;">$cadena</span>, <span style="color:#0000FF;">$arr_palabras</span><span style="color:#006600; font-weight:bold;">&#41;</span> <span style="color:#006600; font-weight:bold;">&#123;</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color:#616100;">if</span> <span style="color:#006600; font-weight:bold;">&#40;</span>!<a href="http://www.php.net/is_array" target="_blank"><span style="color:#000066;">is_array</span></a> <span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#0000FF;">$arr_palabras</span><span style="color:#006600; font-weight:bold;">&#41;</span> || <a href="http://www.php.net/empty" target="_blank"><span style="color:#000066;">empty</span></a> <span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#0000FF;">$arr_palabras</span><span style="color:#006600; font-weight:bold;">&#41;</span> || !<a href="http://www.php.net/is_string" target="_blank"><span style="color:#000066;">is_string</span></a> <span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#0000FF;">$cadena</span><span style="color:#006600; font-weight:bold;">&#41;</span><span style="color:#006600; font-weight:bold;">&#41;</span> <span style="color:#006600; font-weight:bold;">&#123;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color:#616100;">return</span> <span style="color:#000000; font-weight:bold;">false</span>;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color:#006600; font-weight:bold;">&#125;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color:#0000FF;">$str_palabras</span> = <a href="http://www.php.net/implode" target="_blank"><span style="color:#000066;">implode</span></a> <span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#FF0000;">'|'</span>, <span style="color:#0000FF;">$arr_palabras</span><span style="color:#006600; font-weight:bold;">&#41;</span>;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;&nbsp; &nbsp;<span style="color:#616100;">return</span> <a href="http://www.php.net/preg_replace" target="_blank"><span style="color:#000066;">preg_replace</span></a> <span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#FF0000;">'@<span style="color:#000099; font-weight:bold;">\b</span>('</span>.<span style="color:#0000FF;">$str_palabras</span>.<span style="color:#FF0000;">')<span style="color:#000099; font-weight:bold;">\b</span>@si'</span>, <span style="color:#FF0000;">'&lt;strong style=&quot;background-color:yellow&quot;&gt;$1&lt;/strong&gt;'</span>, <span style="color:#0000FF;">$cadena</span><span style="color:#006600; font-weight:bold;">&#41;</span>;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#006600; font-weight:bold;">&#125;</span> </div>
</li>
</ol>
</div>
</div>
</div>
<p></p>
<p>y se utiliza de la siguiente manera:</p>
<div class="igBar"><span id="lphp-28"><a href="#" onclick="javascript:showPlainTxt('php-28'); return false;">Texto Plano</a></span></div>
<div class="syntax_hilite"><span class="langName">PHP:</span>
<div id="php-28">
<div class="php">
<ol>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<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-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#0000FF;">$Texto</span> = <span style="color:#FF0000;">"Lorem ipsum dolor sit amet, consectetur adipiscing elit. Ut adipiscing risus nec arcu interdum at lobortis neque auctor. Morbi in gravida ipsum. Nunc imperdiet, metus sit amet fermentum volutpat, nisi tortor auctor dui, sed porttitor augue mi vitae arcu. Mauris vitae ante sit amet elit tincidunt eleifend et tempor est. Aenean vitae viverra velit. Maecenas pulvinar dolor at ante eleifend vitae fermentum dui auctor. Pellentesque fringilla ultrices odio, vitae elementum lorem gravida in. Curabitur tincidunt sagittis luctus. Cras sit amet sagittis sapien. Nunc tempus dapibus nibh, et posuere nibh aliquam in. "</span>;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#0000FF;">$Palabras</span> = <a href="http://www.php.net/array" target="_blank"><span style="color:#000066;">array</span></a><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#FF0000;">"Lorem"</span>,<span style="color:#FF0000;">"sit"</span>,<span style="color:#FF0000;">"amet"</span><span style="color:#006600; font-weight:bold;">&#41;</span>;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<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;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><a href="http://www.php.net/echo" target="_blank"><span style="color:#000066;">echo</span></a> highlight<span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#0000FF;">$Texto</span>, <span style="color:#0000FF;">$Palabras</span><span style="color:#006600; font-weight:bold;">&#41;</span>;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<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>
</div>
<p></p>
]]></content:encoded>
			<wfw:commentRss>http://ayuda.fotopex.com/programacion/php/resaltar-palabras-de-una-busqueda-con-php/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Acortar URL con PHP</title>
		<link>http://ayuda.fotopex.com/programacion/php/acortar-url-con-php/</link>
		<comments>http://ayuda.fotopex.com/programacion/php/acortar-url-con-php/#comments</comments>
		<pubDate>Wed, 11 Aug 2010 23:14:14 +0000</pubDate>
		<dc:creator>Mr. FotoPex</dc:creator>
				<category><![CDATA[php]]></category>
		<category><![CDATA[acortar]]></category>
		<category><![CDATA[URL]]></category>

		<guid isPermaLink="false">http://ayuda.fotopex.com/?p=781</guid>
		<description><![CDATA[Vamos a ver como podemos acortar una dirección url con el servicio tinyurl y php, y es que en ocasiones nos excedemos con las direcciones url y es complicado manejarlas en mensajes de correo electrónico o publicarlas en algún servicio. Texto Plano PHP: &#60;?php function myUrl&#40;$url&#41;&#123; &#160; &#160; $apiurl = "http://tinyurl.com/api-create.php?url=".$url; &#160; &#160; $url_corta = [...]]]></description>
			<content:encoded><![CDATA[<p><img src="http://ayuda.fotopex.com/wp-content/uploads/2010/08/tiny-230x230.png" alt="" title="tiny" width="230" height="230" class="alignleft size-thumbnail wp-image-784" /><br />
Vamos a ver como podemos acortar una dirección <strong>url </strong>con el  servicio <strong>tinyurl</strong> y php, y es que en ocasiones nos excedemos con las direcciones url y es complicado manejarlas en mensajes de correo electrónico o publicarlas en algún servicio.</p>
<div style="padding: 5px; float: right; " >
 <script type="text/javascript"><!--
google_ad_client = "pub-6087605660472467";
/* ayuda-foto-adsense-cuadro300x250, creado 4/12/08 */ 
google_ad_slot = "1220677556";
google_ad_width = 300;
google_ad_height = 250;
//-->
</script>
<script type="text/javascript"
src="http://pagead2.googlesyndication.com/pagead/show_ads.js">
</script>
</div>
<div style="clear:both;"></div>
<div class="igBar"><span id="lphp-30"><a href="#" onclick="javascript:showPlainTxt('php-30'); return false;">Texto Plano</a></span></div>
<div class="syntax_hilite"><span class="langName">PHP:</span>
<div id="php-30">
<div class="php">
<ol>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<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-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#000000; font-weight:bold;">function</span> myUrl<span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#0000FF;">$url</span><span style="color:#006600; font-weight:bold;">&#41;</span><span style="color:#006600; font-weight:bold;">&#123;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color:#0000FF;">$apiurl</span> = <span style="color:#FF0000;">"http://tinyurl.com/api-create.php?url="</span>.<span style="color:#0000FF;">$url</span>;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color:#0000FF;">$url_corta</span> = <a href="http://www.php.net/file_get_contents" target="_blank"><span style="color:#000066;">file_get_contents</span></a><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#0000FF;">$apiurl</span><span style="color:#006600; font-weight:bold;">&#41;</span>;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color:#616100;">return</span> <span style="color:#0000FF;">$url_corta</span>;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#006600; font-weight:bold;">&#125;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#FF9933; font-style:italic;">//Ejemplo de uso</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><a href="http://www.php.net/echo" target="_blank"><span style="color:#000066;">echo</span></a> myUrl<span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#FF0000;">'http://ayuda.fotopex.com/programacion/php/grafica-vertical/'</span><span style="color:#006600; font-weight:bold;">&#41;</span>;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<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>
</div>
<p></p>
<p>Así quedaría de una forma más ligera.<br />
<a href="http://tinyurl.com/2fp8s57">http://tinyurl.com/2fp8s57</a></p>
]]></content:encoded>
			<wfw:commentRss>http://ayuda.fotopex.com/programacion/php/acortar-url-con-php/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Generador Simple de Claves Aleatorias</title>
		<link>http://ayuda.fotopex.com/programacion/php/generador-simple-de-claves-aleatorias/</link>
		<comments>http://ayuda.fotopex.com/programacion/php/generador-simple-de-claves-aleatorias/#comments</comments>
		<pubDate>Mon, 10 May 2010 19:32:11 +0000</pubDate>
		<dc:creator>Mr. FotoPex</dc:creator>
				<category><![CDATA[php]]></category>
		<category><![CDATA[Aleatorio]]></category>
		<category><![CDATA[Clave]]></category>
		<category><![CDATA[Contraseña]]></category>
		<category><![CDATA[Funciones]]></category>
		<category><![CDATA[Password]]></category>

		<guid isPermaLink="false">http://ayuda.fotopex.com/?p=770</guid>
		<description><![CDATA[Vamos a realizar 4 ejemplos para generar un password aleatorio y así obtener contraseñas de una forma fácil. El primer generador sencillo y simple de claves aleatorias. Utilizaremos las instrucciones md5() y rand(), sin duda el ejemplo más sencillo, fácil y rápido de implementar. Texto Plano PHP: &#60;?php function password_rand_md5&#40;&#41;&#123; &#160; &#160; $longitud = 8; [...]]]></description>
			<content:encoded><![CDATA[<p><img src="http://ayuda.fotopex.com/wp-content/uploads/2010/05/password-fotopex.png" alt="" title="password-fotopex" width="181" height="171" class="alignleft size-full wp-image-771" />Vamos a realizar <strong>4 ejemplos</strong> para generar un password aleatorio y así obtener contraseñas de una forma fácil.<br />
<strong>El primer generador</strong> sencillo y simple de claves aleatorias. Utilizaremos las instrucciones <strong>md5()</strong> y<strong> rand()</strong>, sin duda el ejemplo más <strong>sencillo</strong>,<strong> fácil </strong>y <strong>rápido </strong>de implementar.</p>
<div style="clear:both;"></div>
<div class="igBar"><span id="lphp-35"><a href="#" onclick="javascript:showPlainTxt('php-35'); return false;">Texto Plano</a></span></div>
<div class="syntax_hilite"><span class="langName">PHP:</span>
<div id="php-35">
<div class="php">
<ol>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<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-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#000000; font-weight:bold;">function</span> password_rand_md5<span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#006600; font-weight:bold;">&#41;</span><span style="color:#006600; font-weight:bold;">&#123;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color:#0000FF;">$longitud</span> = <span style="color:#CC66CC;color:#800000;">8</span>; <span style="color:#FF9933; font-style:italic;">// longitud de caracteres que queremos</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color:#0000FF;">$password</span> = <a href="http://www.php.net/substr" target="_blank"><span style="color:#000066;">substr</span></a><span style="color:#006600; font-weight:bold;">&#40;</span><a href="http://www.php.net/md5" target="_blank"><span style="color:#000066;">md5</span></a><span style="color:#006600; font-weight:bold;">&#40;</span><a href="http://www.php.net/rand" target="_blank"><span style="color:#000066;">rand</span></a><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#006600; font-weight:bold;">&#41;</span><span style="color:#006600; font-weight:bold;">&#41;</span>,<span style="color:#CC66CC;color:#800000;">0</span>,<span style="color:#0000FF;">$longitud</span><span style="color:#006600; font-weight:bold;">&#41;</span>;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <a href="http://www.php.net/echo" target="_blank"><span style="color:#000066;">echo</span></a> <span style="color:#0000FF;">$password</span> ; <span style="color:#FF9933; font-style:italic;">// mostramos la contraseña</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#006600; font-weight:bold;">&#125;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">password_rand_md5<span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#006600; font-weight:bold;">&#41;</span>;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<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>
</div>
<p></p>
<p>&nbsp;</p>
<p><span id="more-770"></span></p>
<div style="padding: 5px; float: right; " >
 <script type="text/javascript"><!--
google_ad_client = "pub-6087605660472467";
/* ayuda-foto-adsense-cuadro300x250, creado 4/12/08 */ 
google_ad_slot = "1220677556";
google_ad_width = 300;
google_ad_height = 250;
//-->
</script>
<script type="text/javascript"
src="http://pagead2.googlesyndication.com/pagead/show_ads.js">
</script>
</div>
<p><strong> En el segundo ejemplo</strong> vamos a generar un pasword con una palabra y 2 dígitos, podemos complicarlo si agregamos símbolos como #&#038;)($ etc. Considero que este ejemplo es el más sencillo y con <strong>contraseñas </strong>fáciles de recordar.</p>
<div style="clear:both;"></div>
<div class="igBar"><span id="lphp-36"><a href="#" onclick="javascript:showPlainTxt('php-36'); return false;">Texto Plano</a></span></div>
<div class="syntax_hilite"><span class="langName">PHP:</span>
<div id="php-36">
<div class="php">
<ol>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<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-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#000000; font-weight:bold;">function</span> password_palabra<span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#006600; font-weight:bold;">&#41;</span><span style="color:#006600; font-weight:bold;">&#123;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <a href="http://www.php.net/srand" target="_blank"><span style="color:#000066;">srand</span></a><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#006600; font-weight:bold;">&#40;</span>float<span style="color:#006600; font-weight:bold;">&#41;</span> <a href="http://www.php.net/microtime" target="_blank"><span style="color:#000066;">microtime</span></a><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#006600; font-weight:bold;">&#41;</span> * <span style="color:#CC66CC;color:#800000;">10000000</span><span style="color:#006600; font-weight:bold;">&#41;</span>;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color:#0000FF;">$numeros</span> =&nbsp; <a href="http://www.php.net/range" target="_blank"><span style="color:#000066;">range</span></a><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#CC66CC;color:#800000;">1</span>,<span style="color:#CC66CC;color:#800000;">9</span><span style="color:#006600; font-weight:bold;">&#41;</span>;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color:#0000FF;">$texto</span> = <a href="http://www.php.net/array" target="_blank"><span style="color:#000066;">array</span></a><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#FF0000;">'Enero'</span>, <span style="color:#FF0000;">'Febrero'</span>, <span style="color:#FF0000;">'Marzo'</span>, <span style="color:#FF0000;">'Abril'</span>, <span style="color:#FF0000;">'Mayo'</span>, <span style="color:#FF0000;">'Junio'</span>, <span style="color:#FF0000;">'Julio'</span>,<span style="color:#FF0000;">'Agosto'</span>, <span style="color:#FF0000;">'Septiembre'</span>, <span style="color:#FF0000;">'Octubre'</span>, <span style="color:#FF0000;">'Noviembre'</span>, <span style="color:#FF0000;">'Diciembre'</span><span style="color:#006600; font-weight:bold;">&#41;</span>;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color:#0000FF;">$texto_aleatorio</span> = <a href="http://www.php.net/array_rand" target="_blank"><span style="color:#000066;">array_rand</span></a><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#0000FF;">$texto</span>, <span style="color:#CC66CC;color:#800000;">2</span><span style="color:#006600; font-weight:bold;">&#41;</span>;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color:#0000FF;">$numeros_aleatorios</span> = <a href="http://www.php.net/array_rand" target="_blank"><span style="color:#000066;">array_rand</span></a><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#0000FF;">$numeros</span>, <span style="color:#CC66CC;color:#800000;">2</span><span style="color:#006600; font-weight:bold;">&#41;</span>;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; </div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color:#FF9933; font-style:italic;">// generamos la clave con una palabra y dos numeros al final</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color:#0000FF;">$password</span>= <span style="color:#0000FF;">$texto</span><span style="color:#006600; font-weight:bold;">&#91;</span><span style="color:#0000FF;">$texto_aleatorio</span><span style="color:#006600; font-weight:bold;">&#91;</span><span style="color:#CC66CC;color:#800000;">0</span><span style="color:#006600; font-weight:bold;">&#93;</span><span style="color:#006600; font-weight:bold;">&#93;</span>.<span style="color:#0000FF;">$numeros</span><span style="color:#006600; font-weight:bold;">&#91;</span><span style="color:#0000FF;">$numeros_aleatorios</span><span style="color:#006600; font-weight:bold;">&#91;</span><span style="color:#CC66CC;color:#800000;">0</span><span style="color:#006600; font-weight:bold;">&#93;</span><span style="color:#006600; font-weight:bold;">&#93;</span>.<span style="color:#0000FF;">$numeros</span><span style="color:#006600; font-weight:bold;">&#91;</span><span style="color:#0000FF;">$numeros_aleatorios</span><span style="color:#006600; font-weight:bold;">&#91;</span><span style="color:#CC66CC;color:#800000;">1</span><span style="color:#006600; font-weight:bold;">&#93;</span><span style="color:#006600; font-weight:bold;">&#93;</span>;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color:#FF9933; font-style:italic;">// devolvemos la contraseña</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color:#616100;">return</span> <span style="color:#0000FF;">$password</span>;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#006600; font-weight:bold;">&#125;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#0000FF;">$password</span> = password_palabra<span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#006600; font-weight:bold;">&#41;</span>;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#FF9933; font-style:italic;">// devuelve algocom Septiembre37</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><a href="http://www.php.net/echo" target="_blank"><span style="color:#000066;">echo</span></a> <span style="color:#0000FF;">$password</span>.<span style="color:#FF0000;">'&lt;br /&gt;'</span>;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<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>
</div>
<p></p>
<p><strong>En el tercer ejemplo</strong> vamos a componer el <strong>password </strong>con letras aleatorias y de igual forma agregaremos 2 dígitos.</p>
<div class="igBar"><span id="lphp-37"><a href="#" onclick="javascript:showPlainTxt('php-37'); return false;">Texto Plano</a></span></div>
<div class="syntax_hilite"><span class="langName">PHP:</span>
<div id="php-37">
<div class="php">
<ol>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<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-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#000000; font-weight:bold;">function</span> password_rand<span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#0000FF;">$longitud</span> = <span style="color:#CC66CC;color:#800000;">7</span><span style="color:#006600; font-weight:bold;">&#41;</span><span style="color:#006600; font-weight:bold;">&#123;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color:#0000FF;">$letras</span> = <a href="http://www.php.net/range" target="_blank"><span style="color:#000066;">range</span></a><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#FF0000;">'a'</span>,<span style="color:#FF0000;">'z'</span><span style="color:#006600; font-weight:bold;">&#41;</span>;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color:#0000FF;">$numeros</span> =&nbsp; <a href="http://www.php.net/range" target="_blank"><span style="color:#000066;">range</span></a><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#CC66CC;color:#800000;">1</span>,<span style="color:#CC66CC;color:#800000;">9</span><span style="color:#006600; font-weight:bold;">&#41;</span>;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color:#0000FF;">$numeros_aleatorios</span> = <a href="http://www.php.net/array_rand" target="_blank"><span style="color:#000066;">array_rand</span></a><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#0000FF;">$numeros</span>, <span style="color:#CC66CC;color:#800000;">2</span><span style="color:#006600; font-weight:bold;">&#41;</span>;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <a href="http://www.php.net/srand" target="_blank"><span style="color:#000066;">srand</span></a><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#006600; font-weight:bold;">&#40;</span>float<span style="color:#006600; font-weight:bold;">&#41;</span> <a href="http://www.php.net/microtime" target="_blank"><span style="color:#000066;">microtime</span></a><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#006600; font-weight:bold;">&#41;</span> * <span style="color:#CC66CC;color:#800000;">10000000</span><span style="color:#006600; font-weight:bold;">&#41;</span>; </div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; </div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color:#0000FF;">$password</span> = <span style="color:#FF0000;">''</span>;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color:#0000FF;">$rand_keys</span> = <a href="http://www.php.net/array_rand" target="_blank"><span style="color:#000066;">array_rand</span></a><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#0000FF;">$letras</span>, <span style="color:#0000FF;">$longitud</span><span style="color:#006600; font-weight:bold;">&#41;</span>;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color:#616100;">foreach</span><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#0000FF;">$rand_keys</span> <span style="color:#616100;">as</span> <span style="color:#0000FF;">$key</span><span style="color:#006600; font-weight:bold;">&#41;</span>&nbsp;<span style="color:#006600; font-weight:bold;">&#123;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color:#0000FF;">$password</span> .= <span style="color:#0000FF;">$letras</span><span style="color:#006600; font-weight:bold;">&#91;</span><span style="color:#0000FF;">$key</span><span style="color:#006600; font-weight:bold;">&#93;</span>;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color:#006600; font-weight:bold;">&#125;</span>&nbsp; &nbsp;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color:#FF9933; font-style:italic;">// agregamos dos numeros al final</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color:#0000FF;">$password</span> = <a href="http://www.php.net/substr" target="_blank"><span style="color:#000066;">substr</span></a><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#0000FF;">$password</span>,<span style="color:#CC66CC;color:#800000;">0</span>,<span style="color:#0000FF;">$longitud</span>-<span style="color:#CC66CC;color:#800000;">2</span><span style="color:#006600; font-weight:bold;">&#41;</span>;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color:#616100;">return</span> <span style="color:#0000FF;">$password</span>.<span style="color:#0000FF;">$numeros</span><span style="color:#006600; font-weight:bold;">&#91;</span><span style="color:#0000FF;">$numeros_aleatorios</span><span style="color:#006600; font-weight:bold;">&#91;</span><span style="color:#CC66CC;color:#800000;">0</span><span style="color:#006600; font-weight:bold;">&#93;</span><span style="color:#006600; font-weight:bold;">&#93;</span>.<span style="color:#0000FF;">$numeros</span><span style="color:#006600; font-weight:bold;">&#91;</span><span style="color:#0000FF;">$numeros_aleatorios</span><span style="color:#006600; font-weight:bold;">&#91;</span><span style="color:#CC66CC;color:#800000;">1</span><span style="color:#006600; font-weight:bold;">&#93;</span><span style="color:#006600; font-weight:bold;">&#93;</span>;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#006600; font-weight:bold;">&#125;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#FF9933; font-style:italic;">// pedimos una clave con 10 characteres</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#0000FF;">$password</span> = password_rand<span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#CC66CC;color:#800000;">10</span><span style="color:#006600; font-weight:bold;">&#41;</span>;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#FF9933; font-style:italic;">// devuelve algo como cejklosv12</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<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;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><a href="http://www.php.net/echo" target="_blank"><span style="color:#000066;">echo</span></a> <span style="color:#0000FF;">$password</span>;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<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>
</div>
<p></p>
<p><strong>Para el cuarto ejemplo</strong> vamos a generar la contraseña alternando vocales y consonantes.</p>
<div class="igBar"><span id="lphp-38"><a href="#" onclick="javascript:showPlainTxt('php-38'); return false;">Texto Plano</a></span></div>
<div class="syntax_hilite"><span class="langName">PHP:</span>
<div id="php-38">
<div class="php">
<ol>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<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-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#000000; font-weight:bold;">function</span> password_rand_alt<span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#0000FF;">$longitud</span>=<span style="color:#CC66CC;color:#800000;">8</span><span style="color:#006600; font-weight:bold;">&#41;</span><span style="color:#006600; font-weight:bold;">&#123;</span>&nbsp; &nbsp; </div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color:#0000FF;">$voc</span> = <a href="http://www.php.net/array" target="_blank"><span style="color:#000066;">array</span></a> <span style="color:#006600; font-weight:bold;">&#40;</span>a,e,i,o,u<span style="color:#006600; font-weight:bold;">&#41;</span>;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color:#0000FF;">$con</span> = <a href="http://www.php.net/array" target="_blank"><span style="color:#000066;">array</span></a> <span style="color:#006600; font-weight:bold;">&#40;</span>b,c,d,f,g,h,j,k,l,m,n,p,q,r,s,t,w,x,y,z<span style="color:#006600; font-weight:bold;">&#41;</span>;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color:#0000FF;">$numeros</span> =&nbsp; <a href="http://www.php.net/range" target="_blank"><span style="color:#000066;">range</span></a><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#CC66CC;color:#800000;">1</span>,<span style="color:#CC66CC;color:#800000;">9</span><span style="color:#006600; font-weight:bold;">&#41;</span>;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color:#0000FF;">$numeros_aleatorios</span> = <a href="http://www.php.net/array_rand" target="_blank"><span style="color:#000066;">array_rand</span></a><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#0000FF;">$numeros</span>, <span style="color:#CC66CC;color:#800000;">2</span><span style="color:#006600; font-weight:bold;">&#41;</span>;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color:#0000FF;">$password</span> = <span style="color:#FF0000;">''</span>;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color:#0000FF;">$inicio</span>&nbsp; = <a href="http://www.php.net/mt_rand" target="_blank"><span style="color:#000066;">mt_rand</span></a><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#CC66CC;color:#800000;">0</span>,<span style="color:#CC66CC;color:#800000;">1</span><span style="color:#006600; font-weight:bold;">&#41;</span>;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color:#616100;">for</span> <span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#0000FF;">$n</span>=<span style="color:#CC66CC;color:#800000;">0</span>; <span style="color:#0000FF;">$n</span>&lt;<span style="color:#0000FF;">$longitud</span>; <span style="color:#0000FF;">$n</span>++<span style="color:#006600; font-weight:bold;">&#41;</span><span style="color:#006600; font-weight:bold;">&#123;</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color:#616100;">if</span> <span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#0000FF;">$inicio</span>==<span style="color:#CC66CC;color:#800000;">1</span><span style="color:#006600; font-weight:bold;">&#41;</span><span style="color:#006600; font-weight:bold;">&#123;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color:#0000FF;">$inicio</span>=<span style="color:#CC66CC;color:#800000;">0</span>;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color:#0000FF;">$password</span> .= <span style="color:#0000FF;">$con</span><span style="color:#006600; font-weight:bold;">&#91;</span><a href="http://www.php.net/mt_rand" target="_blank"><span style="color:#000066;">mt_rand</span></a><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#CC66CC;color:#800000;">0</span>,<a href="http://www.php.net/count" target="_blank"><span style="color:#000066;">count</span></a><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#0000FF;">$con</span><span style="color:#006600; font-weight:bold;">&#41;</span>-<span style="color:#CC66CC;color:#800000;">1</span><span style="color:#006600; font-weight:bold;">&#41;</span><span style="color:#006600; font-weight:bold;">&#93;</span>;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color:#006600; font-weight:bold;">&#125;</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color:#0000FF;">$password</span> .= <span style="color:#0000FF;">$voc</span><span style="color:#006600; font-weight:bold;">&#91;</span><a href="http://www.php.net/mt_rand" target="_blank"><span style="color:#000066;">mt_rand</span></a><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#CC66CC;color:#800000;">0</span>,<a href="http://www.php.net/count" target="_blank"><span style="color:#000066;">count</span></a><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#0000FF;">$voc</span><span style="color:#006600; font-weight:bold;">&#41;</span>-<span style="color:#CC66CC;color:#800000;">1</span><span style="color:#006600; font-weight:bold;">&#41;</span><span style="color:#006600; font-weight:bold;">&#93;</span>;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color:#0000FF;">$password</span> .= <span style="color:#0000FF;">$con</span><span style="color:#006600; font-weight:bold;">&#91;</span><a href="http://www.php.net/mt_rand" target="_blank"><span style="color:#000066;">mt_rand</span></a><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#CC66CC;color:#800000;">0</span>,<a href="http://www.php.net/count" target="_blank"><span style="color:#000066;">count</span></a><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#0000FF;">$con</span><span style="color:#006600; font-weight:bold;">&#41;</span>-<span style="color:#CC66CC;color:#800000;">1</span><span style="color:#006600; font-weight:bold;">&#41;</span><span style="color:#006600; font-weight:bold;">&#93;</span>;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color:#006600; font-weight:bold;">&#125;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color:#0000FF;">$password</span> = <a href="http://www.php.net/substr" target="_blank"><span style="color:#000066;">substr</span></a><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#0000FF;">$password</span>,<span style="color:#CC66CC;color:#800000;">0</span>,<span style="color:#0000FF;">$longitud</span>-<span style="color:#CC66CC;color:#800000;">2</span><span style="color:#006600; font-weight:bold;">&#41;</span>;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color:#616100;">return</span> <span style="color:#0000FF;">$password</span>.<span style="color:#0000FF;">$numeros</span><span style="color:#006600; font-weight:bold;">&#91;</span><span style="color:#0000FF;">$numeros_aleatorios</span><span style="color:#006600; font-weight:bold;">&#91;</span><span style="color:#CC66CC;color:#800000;">0</span><span style="color:#006600; font-weight:bold;">&#93;</span><span style="color:#006600; font-weight:bold;">&#93;</span>.<span style="color:#0000FF;">$numeros</span><span style="color:#006600; font-weight:bold;">&#91;</span><span style="color:#0000FF;">$numeros_aleatorios</span><span style="color:#006600; font-weight:bold;">&#91;</span><span style="color:#CC66CC;color:#800000;">1</span><span style="color:#006600; font-weight:bold;">&#93;</span><span style="color:#006600; font-weight:bold;">&#93;</span>;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#006600; font-weight:bold;">&#125;</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#FF9933; font-style:italic;">// pedimos una clave con 10 characteres</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#0000FF;">$password</span> = password_rand_alt<span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#CC66CC;color:#800000;">10</span><span style="color:#006600; font-weight:bold;">&#41;</span>;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#FF9933; font-style:italic;">//devuelve algo como etopoyar36</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><a href="http://www.php.net/echo" target="_blank"><span style="color:#000066;">echo</span></a> <span style="color:#0000FF;">$password</span>;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<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>
</div>
<p></p>
<p>Si deseas puedes bajar el archivo de ejemplo en <a href='http://ayuda.fotopex.com/wp-content/uploads/2010/05/generador-claves.zip'>este enlace con el nombre de generador-claves.zip</a>.</p>
<p>Puedes ejecutar un ejemplo en <a href="http://ayuda.fotopex.com/ejemplos/generador-claves.php">este enlace</a>.</p>
]]></content:encoded>
			<wfw:commentRss>http://ayuda.fotopex.com/programacion/php/generador-simple-de-claves-aleatorias/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Devolver un Array en una Funcion con Return</title>
		<link>http://ayuda.fotopex.com/programacion/php/devolver-un-array-en-una-funcion-con-return/</link>
		<comments>http://ayuda.fotopex.com/programacion/php/devolver-un-array-en-una-funcion-con-return/#comments</comments>
		<pubDate>Sat, 01 May 2010 20:42:19 +0000</pubDate>
		<dc:creator>Mr. FotoPex</dc:creator>
				<category><![CDATA[php]]></category>
		<category><![CDATA[array]]></category>
		<category><![CDATA[Función]]></category>

		<guid isPermaLink="false">http://ayuda.fotopex.com/?p=766</guid>
		<description><![CDATA[La idea es simple: vamos a devolver un array con return dentro de una función, después creas un segundo array al cual se le pasaran los datos que devuelve la función. Aquí esta un ejemplo muy sencillo: Texto Plano PHP: &#60;?php //creamos nuestra función. function saludo&#40;&#41;&#123; &#160; $matriz = array&#40;"Gracias", "por visitar", "FotoPex.com"&#41;; &#160; return [...]]]></description>
			<content:encoded><![CDATA[<p><img src="http://ayuda.fotopex.com/wp-content/uploads/2010/05/devolver-array-return.png" alt="" title="devolver-array-return" width="500" height="221" class="aligncenter size-full wp-image-767" /><br />
La idea es simple: vamos a devolver un array con return dentro de una función, después creas un segundo <strong>array </strong>al cual se le pasaran los datos que devuelve la función.</p>
<p>Aquí esta un ejemplo muy sencillo:<br />
<span id="more-766"></span></p>
<div class="igBar"><span id="lphp-40"><a href="#" onclick="javascript:showPlainTxt('php-40'); return false;">Texto Plano</a></span></div>
<div class="syntax_hilite"><span class="langName">PHP:</span>
<div id="php-40">
<div class="php">
<ol>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<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-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#FF9933; font-style:italic;">//creamos nuestra función.</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#000000; font-weight:bold;">function</span> saludo<span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#006600; font-weight:bold;">&#41;</span><span style="color:#006600; font-weight:bold;">&#123;</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; <span style="color:#0000FF;">$matriz</span> = <a href="http://www.php.net/array" target="_blank"><span style="color:#000066;">array</span></a><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#FF0000;">"Gracias"</span>, <span style="color:#FF0000;">"por visitar"</span>, <span style="color:#FF0000;">"FotoPex.com"</span><span style="color:#006600; font-weight:bold;">&#41;</span>;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; <span style="color:#616100;">return</span> <span style="color:#0000FF;">$matriz</span>; <span style="color:#FF9933; font-style:italic;">// regresamos el arreglo.</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#006600; font-weight:bold;">&#125;</span>&nbsp; </div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; <span style="color:#0000FF;">$mostrar</span>=<a href="http://www.php.net/array" target="_blank"><span style="color:#000066;">array</span></a><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#006600; font-weight:bold;">&#41;</span>;&nbsp; <span style="color:#FF9933; font-style:italic;">// declaramos la nueva variable.</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; <span style="color:#0000FF;">$mostrar</span>=saludo<span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#006600; font-weight:bold;">&#41;</span>; <span style="color:#FF9933; font-style:italic;">// aquí atrapamos los valores del array devuelto por la función</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; <span style="color:#FF9933; font-style:italic;">// mostramos el resultado</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; <a href="http://www.php.net/echo" target="_blank"><span style="color:#000066;">echo</span></a> <span style="color:#0000FF;">$mostrar</span><span style="color:#006600; font-weight:bold;">&#91;</span><span style="color:#CC66CC;color:#800000;">0</span><span style="color:#006600; font-weight:bold;">&#93;</span>.<span style="color:#FF0000;">' '</span>.<span style="color:#0000FF;">$mostrar</span><span style="color:#006600; font-weight:bold;">&#91;</span><span style="color:#CC66CC;color:#800000;">1</span><span style="color:#006600; font-weight:bold;">&#93;</span>.<span style="color:#FF0000;">' '</span>.<span style="color:#0000FF;">$mostrar</span><span style="color:#006600; font-weight:bold;">&#91;</span><span style="color:#CC66CC;color:#800000;">2</span><span style="color:#006600; font-weight:bold;">&#93;</span>;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<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>
</div>
<p></p>
<p>
 <script type="text/javascript"><!--
google_ad_client = "pub-6087605660472467";
/* ayuda-foto-adsense-cuadro300x250, creado 4/12/08 */ 
google_ad_slot = "1220677556";
google_ad_width = 300;
google_ad_height = 250;
//-->
</script>
<script type="text/javascript"
src="http://pagead2.googlesyndication.com/pagead/show_ads.js">
</script>
</p>
]]></content:encoded>
			<wfw:commentRss>http://ayuda.fotopex.com/programacion/php/devolver-un-array-en-una-funcion-con-return/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Gráfica Vertical</title>
		<link>http://ayuda.fotopex.com/programacion/php/grafica-vertical/</link>
		<comments>http://ayuda.fotopex.com/programacion/php/grafica-vertical/#comments</comments>
		<pubDate>Sat, 01 May 2010 20:11:50 +0000</pubDate>
		<dc:creator>Mr. FotoPex</dc:creator>
				<category><![CDATA[php]]></category>
		<category><![CDATA[colores]]></category>
		<category><![CDATA[Gráfica]]></category>
		<category><![CDATA[Vertical]]></category>

		<guid isPermaLink="false">http://ayuda.fotopex.com/?p=762</guid>
		<description><![CDATA[Aprovechando que hemos lanzado el concurso para seleccionar a la Señorita Prepa Colosio 2010 y Chico Prepa Colosio 2010, vamos a mostrarte como hacer una Gráfica Vertical. En el siguiente ejemplo vamos a usar dos tablas: encuestas y respuestas, la idea como siempre es que entiendas lo básico y después podrías mejorarlo. Texto Plano PHP: [...]]]></description>
			<content:encoded><![CDATA[<p><img src="http://ayuda.fotopex.com/wp-content/uploads/2010/05/grafica-vertical.png" alt="" title="grafica-vertical" width="601" height="158" class="aligncenter size-full wp-image-763" /><br />
Aprovechando que hemos lanzado el concurso para seleccionar a la <a href="http://votapex.com/?idPoll=2" target="_blank">Señorita Prepa Colosio 2010</a> y <a href="http://votapex.com/?idPoll=1" target="_blank">Chico Prepa Colosio 2010</a>, vamos a mostrarte como hacer una Gráfica Vertical.</p>
<div style="padding: 5px; float: right; " >
 <script type="text/javascript"><!--
google_ad_client = "pub-6087605660472467";
/* ayuda-foto-adsense-cuadro300x250, creado 4/12/08 */ 
google_ad_slot = "1220677556";
google_ad_width = 300;
google_ad_height = 250;
//-->
</script>
<script type="text/javascript"
src="http://pagead2.googlesyndication.com/pagead/show_ads.js">
</script>
</div>
<p>En el siguiente ejemplo vamos a usar dos tablas: encuestas y respuestas, la idea como siempre es que entiendas lo básico y después podrías mejorarlo.</p>
<div style="clear:both;"></div>
<p><span id="more-762"></span></p>
<div class="igBar"><span id="lphp-43"><a href="#" onclick="javascript:showPlainTxt('php-43'); return false;">Texto Plano</a></span></div>
<div class="syntax_hilite"><span class="langName">PHP:</span>
<div id="php-43">
<div class="php">
<ol>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<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-weight: bold;color:#26536A;">
<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;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#008000;">/****************************************</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#008000;">* Grafica vertical en base a dos tablas *</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#008000;">*&nbsp; &nbsp; &nbsp; www.ayuda.FotoPex.com&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; *</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#008000;">*&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;*</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#008000;">*****************************************/</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<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;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#000000; font-weight:bold;">function</span> grafica_encuesta_vertical<span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#0000FF;">$idEncuesta</span>=<span style="color:#CC66CC;color:#800000;">0</span><span style="color:#006600; font-weight:bold;">&#41;</span><span style="color:#006600; font-weight:bold;">&#123;</span>&nbsp; </div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color:#FF9933; font-style:italic;">// seleccionamos los colores que utilizaremos en cada barra</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color:#0000FF;">$colores</span> = <a href="http://www.php.net/array" target="_blank"><span style="color:#000066;">array</span></a><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#FF0000;">'3366CC'</span>,<span style="color:#FF0000;">'DC3912'</span>,<span style="color:#FF0000;">'109618'</span>,<span style="color:#FF0000;">'FF9900'</span>,<span style="color:#FF0000;">'375181'</span>,<span style="color:#FF0000;">'FFCC33'</span>,<span style="color:#FF0000;">'082454'</span>,<span style="color:#FF0000;">'a3129e'</span>,<span style="color:#FF0000;">'e57e0f'</span>,<span style="color:#FF0000;">'256605'</span><span style="color:#006600; font-weight:bold;">&#41;</span>;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color:#0000FF;">$rs</span>=<a href="http://www.php.net/mysql_query" target="_blank"><span style="color:#000066;">mysql_query</span></a><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#FF0000;">'SELECT encuestas.pregunta FROM `respuestas` </span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#FF0000;">&nbsp; &nbsp; INNER JOIN encuestas ON encuestas.id = respuestas.id_poll </span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#FF0000;">&nbsp; &nbsp; WHERE respuestas.id_poll = <span style="color:#000099; font-weight:bold;">\'</span>'</span>.<span style="color:#0000FF;">$idEncuesta</span>.<span style="color:#FF0000;">'<span style="color:#000099; font-weight:bold;">\'</span> ;'</span><span style="color:#006600; font-weight:bold;">&#41;</span>or <a href="http://www.php.net/die" target="_blank"><span style="color:#000066;">die</span></a><span style="color:#006600; font-weight:bold;">&#40;</span><a href="http://www.php.net/mysql_error" target="_blank"><span style="color:#000066;">mysql_error</span></a><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#006600; font-weight:bold;">&#41;</span><span style="color:#006600; font-weight:bold;">&#41;</span>;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color:#0000FF;">$total_votos</span> = <a href="http://www.php.net/mysql_num_rows" target="_blank"><span style="color:#000066;">mysql_num_rows</span></a><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#0000FF;">$rs</span><span style="color:#006600; font-weight:bold;">&#41;</span>; <span style="color:#FF9933; font-style:italic;">// obtenemos el total de los votos</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color:#0000FF;">$rowPreg</span> = <a href="http://www.php.net/mysql_fetch_object" target="_blank"><span style="color:#000066;">mysql_fetch_object</span></a><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#0000FF;">$rs</span><span style="color:#006600; font-weight:bold;">&#41;</span>;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color:#0000FF;">$NombreEncuesta</span> = <span style="color:#0000FF;">$rowPreg</span>-&gt;<span style="color:#006600;">pregunta</span>;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <a href="http://www.php.net/mysql_free_result" target="_blank"><span style="color:#000066;">mysql_free_result</span></a><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#0000FF;">$rs</span><span style="color:#006600; font-weight:bold;">&#41;</span>;&nbsp;&nbsp;&nbsp;&nbsp;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color:#FF9933; font-style:italic;">//buscamos las respuestas</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color:#0000FF;">$ssql</span>=<span style="color:#FF0000;">'SELECT `id_nombre` as participante , count( *&nbsp; ) AS votos </span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#FF0000;">&nbsp; &nbsp; FROM `respuestas` </span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#FF0000;">&nbsp; &nbsp; WHERE respuestas.id_poll = <span style="color:#000099; font-weight:bold;">\'</span>'</span>.<span style="color:#0000FF;">$idEncuesta</span>.<span style="color:#FF0000;">'<span style="color:#000099; font-weight:bold;">\'</span> </span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#FF0000;">&nbsp; &nbsp; GROUP BY `id_opcion` LIMIT 10; '</span>; <span style="color:#FF9933; font-style:italic;">// limte de 10 opciones para votar</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color:#0000FF;">$result</span> = <a href="http://www.php.net/mysql_query" target="_blank"><span style="color:#000066;">mysql_query</span></a><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#0000FF;">$ssql</span><span style="color:#006600; font-weight:bold;">&#41;</span>; </div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color:#0000FF;">$numOpciones</span> = <a href="http://www.php.net/mysql_num_rows" target="_blank"><span style="color:#000066;">mysql_num_rows</span></a><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#0000FF;">$result</span><span style="color:#006600; font-weight:bold;">&#41;</span>; <span style="color:#FF9933; font-style:italic;">// obtenenemos el numero real de opciones votadas</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color:#0000FF;">$anchoBarra</span> = <span style="color:#CC66CC;color:#800000;">10</span>;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color:#616100;">if</span><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#0000FF;">$numOpciones</span>&gt; <span style="color:#CC66CC;color:#800000;">0</span><span style="color:#006600; font-weight:bold;">&#41;</span> <span style="color:#0000FF;">$anchoBarra</span> = @<a href="http://www.php.net/round" target="_blank"><span style="color:#000066;">round</span></a><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#CC66CC;color:#800000;">100</span>/<span style="color:#0000FF;">$numOpciones</span><span style="color:#006600; font-weight:bold;">&#41;</span>; <span style="color:#FF9933; font-style:italic;">// se expresara en %</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color:#0000FF;">$ontRowOpt</span> = <span style="color:#CC66CC;color:#800000;">0</span>;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color:#616100;">while</span> <span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#0000FF;">$row</span>=<a href="http://www.php.net/mysql_fetch_object" target="_blank"><span style="color:#000066;">mysql_fetch_object</span></a><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#0000FF;">$result</span><span style="color:#006600; font-weight:bold;">&#41;</span><span style="color:#006600; font-weight:bold;">&#41;</span><span style="color:#006600; font-weight:bold;">&#123;</span>&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color:#0000FF;">$porcentaje</span> = <a href="http://www.php.net/round" target="_blank"><span style="color:#000066;">round</span></a><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#0000FF;">$row</span>-&gt;<span style="color:#006600;">votos</span>/<span style="color:#0000FF;">$total_votos</span><span style="color:#006600; font-weight:bold;">&#41;</span>*<span style="color:#CC66CC;color:#800000;">100</span><span style="color:#006600; font-weight:bold;">&#41;</span>;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color:#0000FF;">$votos_x_opcion</span>=<span style="color:#0000FF;">$row</span>-&gt;<span style="color:#006600;">votos</span>;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color:#0000FF;">$barras</span>.= <span style="color:#FF0000;">'&lt;td height=&quot;100px;&quot; width=&quot;'</span>.<span style="color:#0000FF;">$anchoBarra</span>.<span style="color:#FF0000;">'%&quot; valign=&quot;bottom&quot;&gt;'</span>.<span style="color:#0000FF;">$row</span>-&gt;<span style="color:#006600;">votos</span>.</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color:#FF0000;">'&lt;br /&gt;&lt;div style=&quot;background:#'</span>.<span style="color:#0000FF;">$colores</span><span style="color:#006600; font-weight:bold;">&#91;</span><span style="color:#0000FF;">$ontRowOpt</span><span style="color:#006600; font-weight:bold;">&#93;</span>.<span style="color:#FF0000;">'; height:'</span>.<span style="color:#0000FF;">$porcentaje</span>.<span style="color:#FF0000;">'px;&quot;&gt;&lt;/div&gt;&lt;/td&gt;'</span>;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color:#0000FF;">$footers</span>.= <span style="color:#FF0000;">'&lt;td height=&quot;15px;&quot;&gt;'</span>.<span style="color:#0000FF;">$row</span>-&gt;<span style="color:#006600;">participante</span>.<span style="color:#FF0000;">'&lt;/td&gt;'</span>;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color:#0000FF;">$ontRowOpt</span>++;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color:#006600; font-weight:bold;">&#125;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <a href="http://www.php.net/echo" target="_blank"><span style="color:#000066;">echo</span></a> <span style="color:#FF0000;">'&lt;div class=&quot;box1&quot;&gt;</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#FF0000;">&nbsp; &nbsp; &lt;table height=&quot;170px;&quot; width=&quot;600px;&quot;&gt;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#FF0000;">&nbsp; &nbsp; &lt;tr&nbsp; align=&quot;center&quot;&gt;&lt;td colspan=&quot;'</span>.<span style="color:#0000FF;">$numOpciones</span>.<span style="color:#FF0000;">'&quot;&gt;&lt;b style=&quot;color:#055A91&quot;&gt;'</span>.<a href="http://www.php.net/html_entity_decode" target="_blank"><span style="color:#000066;">html_entity_decode</span></a><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#0000FF;">$NombreEncuesta</span><span style="color:#006600; font-weight:bold;">&#41;</span>.<span style="color:#FF0000;">' '</span>.<span style="color:#0000FF;">$total_votos</span>.<span style="color:#FF0000;">' Votos en Total&lt;/b&gt;&lt;br /&gt;&lt;/td&gt;&lt;/tr&gt;</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#FF0000;">&nbsp; &nbsp; &lt;tr&nbsp; align=&quot;center&quot;&gt;'</span>.<span style="color:#0000FF;">$barras</span>.<span style="color:#FF0000;">'&lt;/tr&gt;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#FF0000;">&nbsp; &nbsp; &lt;tr&nbsp; align=&quot;center&quot;&gt;'</span>.<span style="color:#0000FF;">$footers</span>.<span style="color:#FF0000;">'&lt;/tr&gt;</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#FF0000;">&nbsp; &nbsp; &lt;/table&gt;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#FF0000;">&nbsp; &nbsp; &lt;/div&gt;</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#FF0000;">&nbsp; &nbsp; &lt;div class=&quot;divClear&quot;&gt;&lt;/div&gt;'</span>;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#006600; font-weight:bold;">&#125;</span><span style="color:#000000; font-weight:bold;">?&gt;</span> </div>
</li>
</ol>
</div>
</div>
</div>
<p></p>
<p>ahora solo necesitamos llamarla </p>
<div class="igBar"><span id="lphp-44"><a href="#" onclick="javascript:showPlainTxt('php-44'); return false;">Texto Plano</a></span></div>
<div class="syntax_hilite"><span class="langName">PHP:</span>
<div id="php-44">
<div class="php">
<ol>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#000000; font-weight:bold;">&lt;?php</span> grafica_encuesta_vertical<span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#0000FF;">$idPoll</span><span style="color:#006600; font-weight:bold;">&#41;</span>; <span style="color:#000000; font-weight:bold;">?&gt;</span> </div>
</li>
</ol>
</div>
</div>
</div>
<p></p>
<p>Algunas veces hay problemas con el Copy/Paste, así que este es el archivo del ejemplo.<br />
<a href='http://ayuda.fotopex.com/wp-content/uploads/2010/05/ejemplo-grafica-vertical.zip'>Ejemplo Gráfica Vertical</a></p>
]]></content:encoded>
			<wfw:commentRss>http://ayuda.fotopex.com/programacion/php/grafica-vertical/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Convertir Acentos a minúsculas en php</title>
		<link>http://ayuda.fotopex.com/programacion/php/convertir-acentos-a-minusculas-en-php/</link>
		<comments>http://ayuda.fotopex.com/programacion/php/convertir-acentos-a-minusculas-en-php/#comments</comments>
		<pubDate>Tue, 23 Mar 2010 16:20:07 +0000</pubDate>
		<dc:creator>Mr. FotoPex</dc:creator>
				<category><![CDATA[php]]></category>
		<category><![CDATA[mb_strtolower]]></category>
		<category><![CDATA[string]]></category>
		<category><![CDATA[strtolower]]></category>

		<guid isPermaLink="false">http://ayuda.fotopex.com/?p=758</guid>
		<description><![CDATA[mb_strtolower devuelve un string con todas sus letras en minúsculas. Ejemplo: Texto Plano PHP: echo strtolower&#40;'LEÓN'&#41; Se queda ígual: leÓn Y utilizando la función mb_strtolower con la codificación utf8: Texto Plano PHP: $str = mb_strtolower&#40; $str,"UTF-8"&#41;;]]></description>
			<content:encoded><![CDATA[<div style="padding: 5px; float: right; " >
 <script type="text/javascript"><!--
google_ad_client = "pub-6087605660472467";
/* ayuda-foto-adsense-cuadro300x250, creado 4/12/08 */ 
google_ad_slot = "1220677556";
google_ad_width = 300;
google_ad_height = 250;
//-->
</script>
<script type="text/javascript"
src="http://pagead2.googlesyndication.com/pagead/show_ads.js">
</script>
</div>
<p><strong>mb_strtolower</strong> devuelve un string con todas sus letras en <strong>minúsculas</strong>.<br />
Ejemplo:</p>
<div style="clear:both;"></div>
<div class="igBar"><span id="lphp-47"><a href="#" onclick="javascript:showPlainTxt('php-47'); return false;">Texto Plano</a></span></div>
<div class="syntax_hilite"><span class="langName">PHP:</span>
<div id="php-47">
<div class="php">
<ol>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><a href="http://www.php.net/echo" target="_blank"><span style="color:#000066;">echo</span></a> <a href="http://www.php.net/strtolower" target="_blank"><span style="color:#000066;">strtolower</span></a><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#FF0000;">'LEÓN'</span><span style="color:#006600; font-weight:bold;">&#41;</span> </div>
</li>
</ol>
</div>
</div>
</div>
<p>
Se queda ígual: leÓn</p>
<p>Y utilizando la función <strong>mb_strtolower</strong> con la codificación utf8:</p>
<div class="igBar"><span id="lphp-48"><a href="#" onclick="javascript:showPlainTxt('php-48'); return false;">Texto Plano</a></span></div>
<div class="syntax_hilite"><span class="langName">PHP:</span>
<div id="php-48">
<div class="php">
<ol>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#0000FF;">$str</span> = <a href="http://www.php.net/mb_strtolower" target="_blank"><span style="color:#000066;">mb_strtolower</span></a><span style="color:#006600; font-weight:bold;">&#40;</span> <span style="color:#0000FF;">$str</span>,<span style="color:#FF0000;">"UTF-8"</span><span style="color:#006600; font-weight:bold;">&#41;</span>; </div>
</li>
</ol>
</div>
</div>
</div>
<p></p>
]]></content:encoded>
			<wfw:commentRss>http://ayuda.fotopex.com/programacion/php/convertir-acentos-a-minusculas-en-php/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
