<?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>Zarpele! Linux and Software Libre &#187; Paginas</title>
	<atom:link href="http://www.zarpele.com.ar/tag/paginas/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.zarpele.com.ar</link>
	<description>GNU/Linux, Programación, Tecnologia...</description>
	<lastBuildDate>Thu, 12 Jan 2012 14:26:01 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.1.2</generator>
		<item>
		<title>Formatear código PHP de forma fácil y rápida&#8230;</title>
		<link>http://www.zarpele.com.ar/2010/06/formatear-codigo-php-de-forma-facil-y-rapida/</link>
		<comments>http://www.zarpele.com.ar/2010/06/formatear-codigo-php-de-forma-facil-y-rapida/#comments</comments>
		<pubDate>Tue, 15 Jun 2010 03:34:24 +0000</pubDate>
		<dc:creator>Zarpele</dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[Paginas]]></category>
		<category><![CDATA[Php]]></category>
		<category><![CDATA[Programación]]></category>
		<category><![CDATA[Programacion Web]]></category>
		<category><![CDATA[Tips]]></category>

		<guid isPermaLink="false">http://www.zarpele.com.ar/?p=1857</guid>
		<description><![CDATA[<p><center><img src="http://texttoimg.com/PHP%20Beautifier_puritan%20(bold)_36_004080.gif" alt="phpbe" /></center></p>
<p>El formato adecuado hace que el código más fácil de leer y entender. <a href="http://phpbeautifier.com/" target="_blank">PHP Beautifier</a> analiza su código y le da formato con estilo a su elección. </p>
<p>Muchas veces se nos presenta la ocasión de ver código ajeno o de procedencias dudosas <img src='http://www.zarpele.com.ar/wp-includes/images/smilies/icon_biggrin.gif' alt=':D' class='wp-smiley' /> , por lo que para leerlo y comprenderlo mejor, es necesario que tenga un formato adecuado para el mismo&#8230;</p>
<p>De que estoy hablando???</p>
<p>Por ejemplo nos pasan este script&#8230;</p>
<pre class="brush: php;">
&lt;?php

  header('Content-Type: text/javascript');  header('Cache-Control: no-cache');
  header('Pragma: no-cache');  define(&quot;MAX_PRICE&quot;, 100.0); // $100.00
  define(&quot;MAX_PRICE_CHANGE&quot;, 0.02); // +/- 2%

  echo '[';
  $q = trim($_GET['q']);
  if ($q) { $symbols = explode(' ', $q);

    for ($i=0; $i&lt;count($symbols); $i++) { $price = lcg_value() * MAX_PRICE;
      $change = $price * MAX_PRICE_CHANGE * (lcg_value() * 2.0 - 1.0);

      echo '{';      echo &quot;\&quot;symbol\&quot;:\&quot;$symbols[$i]\&quot;,&quot;;
      echo &quot;\&quot;price\&quot;:$price,&quot;;                   echo &quot;\&quot;change\&quot;:$change&quot;;
                echo '}';

      if ($i &lt; (count($symbols) - 1))
                                        {
                  echo ',';
}
}
}

   echo ']';
?&gt;</pre>
<p>Como ven esta un poco desordenado, entramos al site de <a href="http://phpbeautifier.com/" target="_blank">PHP Beautifier</a> y copiamos dicho codigo en el textarea (tenemos la opcion de importar un archivo) y seleccionamos el estilo deseado&#8230;</p>
<p>Yo uso Allman style</p>
<blockquote><p>Named for Eric Allman, a Berkeley hacker who wrote a lot of the BSD utilities in it (it is sometimes called BSD style).</p>
<p>Resembles normal indent style in Pascal and Algol. It is the only style other than K&#038;R in widespread use among Java programmers.</p>
<p>Basic indent per level shown here is eight spaces, but four (or sometimes three) spaces are generally preferred by C++ and Java programmers. </p></blockquote>
<p>Le dan a Beautify y walla!</p>
<pre class="brush: php;">
&lt;?php
header('Content-Type: text/javascript');
header('Cache-Control: no-cache');
header('Pragma: no-cache');
define(&quot;MAX_PRICE&quot;, 100.0); // $100.00
define(&quot;MAX_PRICE_CHANGE&quot;, 0.02); // +/- 2%
echo '[';
$q = trim($_GET['q']);

if ($q)
{
	$symbols = explode(' ', $q);
	for ($i = 0; $i &lt; count($symbols); $i++)
	{
		$price = lcg_value() * MAX_PRICE;
		$change = $price * MAX_PRICE_CHANGE * (lcg_value() * 2.0 - 1.0);
		echo '{';
		echo &quot;\&quot;symbol\&quot;:\&quot;$symbols[$i]\&quot;,&quot;;
		echo &quot;\&quot;price\&quot;:$price,&quot;;
		echo &quot;\&quot;change\&quot;:$change&quot;;
		echo '}';
		if ($i &lt; (count($symbols) - 1))
		{
			echo ',';
		}
	}
}

echo ']';
?&gt;
</pre>
<p>Tenemos el código limpio y ordenado. <strong><em>Se preguntaran esto es una pelotudez enorme</em></strong>, la respuesta es no, si tenemos un script de mil lineas por ejemplo, nos tardaríamos el doble en leerlo y entenderlo.</p>
<p>Una de las cosas importantes que debe tener en cuenta un programador, es que ademas que su código funcione, este debe ser fácil de entender y leer por los demás, mucho mas cuando se trabaja en equipo&#8230;</p>
<p>Saludos&#8230;</p>
<!-- Social Bookmarks BEGIN -->
<div class="social_bookmark">
<div class="d1857" style="overflow:hidden; text-align:center;" >
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://buzz.yahoo.com/submit?submitUrl=http%3A%2F%2Fwww.zarpele.com.ar%2F2010%2F06%2Fformatear-codigo-php-de-forma-facil-y-rapida%2F&amp;submitHeadline=Formatear+c%C3%B3digo+PHP+de+forma+f%C3%A1cil+y+r%C3%A1pida%26%238230%3B&amp;submitSummary=" rel="nofollow" title="Add to&nbsp;Buzz"><img class="social_img" src="http://www.zarpele.com.ar/wp-content/plugins/social-bookmarks/images/buzz.png" title="Add to&nbsp;Buzz" alt="Add to&nbsp;Buzz" /></a>
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://del.icio.us/post?url=http%3A%2F%2Fwww.zarpele.com.ar%2F2010%2F06%2Fformatear-codigo-php-de-forma-facil-y-rapida%2F&amp;title=Formatear+c%C3%B3digo+PHP+de+forma+f%C3%A1cil+y+r%C3%A1pida%26%238230%3B" rel="nofollow" title="Add to&nbsp;Del.icio.us"><img class="social_img" src="http://www.zarpele.com.ar/wp-content/plugins/social-bookmarks/images/delicious.png" title="Add to&nbsp;Del.icio.us" alt="Add to&nbsp;Del.icio.us" /></a>
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://digg.com/submit?phase=2&amp;url=http%3A%2F%2Fwww.zarpele.com.ar%2F2010%2F06%2Fformatear-codigo-php-de-forma-facil-y-rapida%2F&amp;title=Formatear+c%C3%B3digo+PHP+de+forma+f%C3%A1cil+y+r%C3%A1pida%26%238230%3B" rel="nofollow" title="Add to&nbsp;digg"><img class="social_img" src="http://www.zarpele.com.ar/wp-content/plugins/social-bookmarks/images/digg.png" title="Add to&nbsp;digg" alt="Add to&nbsp;digg" /></a>
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://www.facebook.com/sharer.php?u=http%3A%2F%2Fwww.zarpele.com.ar%2F2010%2F06%2Fformatear-codigo-php-de-forma-facil-y-rapida%2F" rel="nofollow" title="Add to&nbsp;Facebook"><img class="social_img" src="http://www.zarpele.com.ar/wp-content/plugins/social-bookmarks/images/facebook.png" title="Add to&nbsp;Facebook" alt="Add to&nbsp;Facebook" /></a>
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://www.google.com/bookmarks/mark?op=edit&amp;output=popup&amp;bkmk=http%3A%2F%2Fwww.zarpele.com.ar%2F2010%2F06%2Fformatear-codigo-php-de-forma-facil-y-rapida%2F&amp;title=Formatear+c%C3%B3digo+PHP+de+forma+f%C3%A1cil+y+r%C3%A1pida%26%238230%3B" rel="nofollow" title="Add to&nbsp;Google Bookmarks"><img class="social_img" src="http://www.zarpele.com.ar/wp-content/plugins/social-bookmarks/images/google.png" title="Add to&nbsp;Google Bookmarks" alt="Add to&nbsp;Google Bookmarks" /></a>
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://www.mister-wong.com/index.php?action=addurl&amp;bm_url=http%3A%2F%2Fwww.zarpele.com.ar%2F2010%2F06%2Fformatear-codigo-php-de-forma-facil-y-rapida%2F&amp;bm_description=Formatear+c%C3%B3digo+PHP+de+forma+f%C3%A1cil+y+r%C3%A1pida%26%238230%3B" rel="nofollow" title="Add to&nbsp;Mister Wong"><img class="social_img" src="http://www.zarpele.com.ar/wp-content/plugins/social-bookmarks/images/misterwong.png" title="Add to&nbsp;Mister Wong" alt="Add to&nbsp;Mister Wong" /></a>
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://www.netscape.com/submit/?U=http%3A%2F%2Fwww.zarpele.com.ar%2F2010%2F06%2Fformatear-codigo-php-de-forma-facil-y-rapida%2F&amp;T=Formatear+c%C3%B3digo+PHP+de+forma+f%C3%A1cil+y+r%C3%A1pida%26%238230%3B" rel="nofollow" title="Add to&nbsp;Netscape"><img class="social_img" src="http://www.zarpele.com.ar/wp-content/plugins/social-bookmarks/images/netscape.png" title="Add to&nbsp;Netscape" alt="Add to&nbsp;Netscape" /></a>
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://reddit.com/submit?url=http%3A%2F%2Fwww.zarpele.com.ar%2F2010%2F06%2Fformatear-codigo-php-de-forma-facil-y-rapida%2F&amp;title=Formatear+c%C3%B3digo+PHP+de+forma+f%C3%A1cil+y+r%C3%A1pida%26%238230%3B" rel="nofollow" title="Add to&nbsp;reddit"><img class="social_img" src="http://www.zarpele.com.ar/wp-content/plugins/social-bookmarks/images/reddit.png" title="Add to&nbsp;reddit" alt="Add to&nbsp;reddit" /></a>
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://www.stumbleupon.com/submit?url=http%3A%2F%2Fwww.zarpele.com.ar%2F2010%2F06%2Fformatear-codigo-php-de-forma-facil-y-rapida%2F&amp;title=Formatear+c%C3%B3digo+PHP+de+forma+f%C3%A1cil+y+r%C3%A1pida%26%238230%3B" rel="nofollow" title="Add to&nbsp;Stumble Upon"><img class="social_img" src="http://www.zarpele.com.ar/wp-content/plugins/social-bookmarks/images/stumbleupon.png" title="Add to&nbsp;Stumble Upon" alt="Add to&nbsp;Stumble Upon" /></a>
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://www.technorati.com/faves?add=http%3A%2F%2Fwww.zarpele.com.ar%2F2010%2F06%2Fformatear-codigo-php-de-forma-facil-y-rapida%2F" rel="nofollow" title="Add to&nbsp;Technorati"><img class="social_img" src="http://www.zarpele.com.ar/wp-content/plugins/social-bookmarks/images/technorati.png" title="Add to&nbsp;Technorati" alt="Add to&nbsp;Technorati" /></a>
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://tipd.com/submit.php?url=http%3A%2F%2Fwww.zarpele.com.ar%2F2010%2F06%2Fformatear-codigo-php-de-forma-facil-y-rapida%2F" rel="nofollow" title="Add to&nbsp;Tip'd"><img class="social_img" src="http://www.zarpele.com.ar/wp-content/plugins/social-bookmarks/images/tipd.png" title="Add to&nbsp;Tip'd" alt="Add to&nbsp;Tip'd" /></a>
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://twitter.com/home/?status=Check+out+Formatear+c%C3%B3digo+PHP+de+forma+f%C3%A1cil+y+r%C3%A1pida%26%238230%3B+@+http%3A%2F%2Fwww.zarpele.com.ar%2F2010%2F06%2Fformatear-codigo-php-de-forma-facil-y-rapida%2F" rel="nofollow" title="Add to&nbsp;Twitter"><img class="social_img" src="http://www.zarpele.com.ar/wp-content/plugins/social-bookmarks/images/twitter.png" title="Add to&nbsp;Twitter" alt="Add to&nbsp;Twitter" /></a>
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://myweb2.search.yahoo.com/myresults/bookmarklet?u=http%3A%2F%2Fwww.zarpele.com.ar%2F2010%2F06%2Fformatear-codigo-php-de-forma-facil-y-rapida%2F&amp;t=Formatear+c%C3%B3digo+PHP+de+forma+f%C3%A1cil+y+r%C3%A1pida%26%238230%3B" rel="nofollow" title="Add to&nbsp;Yahoo My Web"><img class="social_img" src="http://www.zarpele.com.ar/wp-content/plugins/social-bookmarks/images/yahoo.png" title="Add to&nbsp;Yahoo My Web" alt="Add to&nbsp;Yahoo My Web" /></a>
<br />
</div>
</div>
<!-- Social Bookmarks END -->
<script type="text/javascript">$$('div.d1857').each( function(e) { e.visualEffect('slide_up',{duration:0.5}) }); </script>]]></description>
		<wfw:commentRss>http://www.zarpele.com.ar/2010/06/formatear-codigo-php-de-forma-facil-y-rapida/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
	</channel>
</rss>

