<?xml version="1.0" encoding="UTF-8"?>
<!-- generator="wordpress/2.0.5" -->
<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/"
	>

<channel>
	<title>Silici0 :: Blog</title>
	<link>http://www.rafaelcunha.com</link>
	<description>Php, JS, JQuery, Ajax e +++</description>
	<pubDate>Tue, 09 Mar 2010 22:05:03 +0000</pubDate>
	<generator>http://wordpress.org/?v=2.0.5</generator>
	<language>en</language>
			<item>
		<title>PHP o bÃ¡sico</title>
		<link>http://www.rafaelcunha.com/2008/12/17/php-o-basico/</link>
		<comments>http://www.rafaelcunha.com/2008/12/17/php-o-basico/#comments</comments>
		<pubDate>Wed, 17 Dec 2008 20:11:28 +0000</pubDate>
		<dc:creator>silici0</dc:creator>
		
		<category>Informatica</category>

		<category>php</category>

		<category>Tutorial</category>

		<guid isPermaLink="false">http://www.rafaelcunha.com/2008/12/17/php-o-basico/</guid>
		<description><![CDATA[Estudando um pouco de PHP, tentarei escrever alguns tutoriais e exemplificar estudos para a CertificaÃ§Ã£o da Zend, comenÃ§ando claro pelo bÃ¡sico...
PHP Tags
Como PHP foi desenhado para ser um processador de textos Ã© necessÃ¡rio tags para identificar o cÃ³digo do PHP, tudo fora destas TAGS serÃ¡ interpretado como saÃ­da de texto, vejamos as tags :

Standard Tags
PLAIN [...]]]></description>
			<content:encoded><![CDATA[<p>Estudando um pouco de PHP, tentarei escrever alguns tutoriais e exemplificar estudos para a CertificaÃ§Ã£o da Zend, comenÃ§ando claro pelo bÃ¡sico...</p>
<h3>PHP Tags</h3>
<p>Como PHP foi desenhado para ser um processador de textos Ã© necessÃ¡rio tags para identificar o cÃ³digo do PHP, tudo fora destas TAGS serÃ¡ interpretado como saÃ­da de texto, vejamos as tags :</p>
<ul>
<li><strong>Standard Tags</strong>
<div class="igBar"><span id="lcode-8"><a href="#" onclick="javascript:showCodeTxt('code-8'); return false;">PLAIN TEXT</a></span></div>
<div class="syntax_hilite"><span class="langName">CODE:</span>
<div id="code-8">
<div class="code">
<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;?php ... <span style="">codigo</span> ... ?&gt; </div>
</li>
</ol>
</div>
</div>
</div>
<p></li>
<li><strong>Short Tags</strong>
<div class="igBar"><span id="lcode-9"><a href="#" onclick="javascript:showCodeTxt('code-9'); return false;">PLAIN TEXT</a></span></div>
<div class="syntax_hilite"><span class="langName">CODE:</span>
<div id="code-9">
<div class="code">
<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;? ... <span style="">codigo</span> ... ?&gt; </div>
</li>
</ol>
</div>
</div>
</div>
<p></li>
<li><strong>Script Tags</strong>
<div class="igBar"><span id="lcode-10"><a href="#" onclick="javascript:showCodeTxt('code-10'); return false;">PLAIN TEXT</a></span></div>
<div class="syntax_hilite"><span class="langName">CODE:</span>
<div id="code-10">
<div class="code">
<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;script language =<span style="color:#CC0000;">"php'&gt; ... codigo ... &lt;/script&gt; </span></div>
</li>
</ol>
</div>
</div>
</div>
<p></li>
<li><strong>ASP Tags</strong>
<div class="igBar"><span id="lcode-11"><a href="#" onclick="javascript:showCodeTxt('code-11'); return false;">PLAIN TEXT</a></span></div>
<div class="syntax_hilite"><span class="langName">CODE:</span>
<div id="code-11">
<div class="code">
<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;% ... <span style="">codigo</span> ... %&gt; </div>
</li>
</ol>
</div>
</div>
</div>
<p></li>
</ul>
<p>O padrÃ£o Ã© o <strong>Standard Tags</strong> que no caso nÃ£o Ã© possivel desabilita-las, por isso Ã© a mais recomendada para o uso.</p>
<h3>Data Types (Tipos de dados)</h3>
<ul>
<li>bollean</li>
<li>int</li>
<li>float</li>
<li>string</li>
</ul>
<p>No caso de valores nÃºmero temos :</p>
<ul>
<li><strong>Decimal </strong><br />
Ex.: 10; -11; 1452;</li>
<li><strong>Octal </strong><br />
ConotaÃ§Ã£o base 8 No php todo nÃºmero comeÃ§ado com 0 (zero) Ã© um nÃºmero octal, veja sobre em : <a href="http://pt.wikipedia.org/wiki/Sistema_octal" onclick="javascript:pageTracker._trackPageview('/outbound/article/http://pt.wikipedia.org/wiki/Sistema_octal');">Wikipedia</a>. Ex.: 0660; 0100;</li>
<li><strong>Hexadecimal</strong><br />
ConotaÃ§Ã£o base 16, saiba sobre no <a href="http://pt.wikipedia.org/wiki/Sistema_hexadecimal" onclick="javascript:pageTracker._trackPageview('/outbound/article/http://pt.wikipedia.org/wiki/Sistema_hexadecimal');">Wikipedia</a>. Ex.: 0x123; 0xA;</li>
</ul>
<h3>Variaveis Variaveis</h3>
<p>Ã‰ este o nome mesmo, Ã© a variavel que o nome Ã© contido em outra variavel, como assim? Veja o exemplo:</p>
<div class="igBar"><span id="lcode-12"><a href="#" onclick="javascript:showCodeTxt('code-12'); return false;">PLAIN TEXT</a></span></div>
<div class="syntax_hilite"><span class="langName">CODE:</span>
<div id="code-12">
<div class="code">
<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;">$name = <span style="color:#CC0000;">'foo'</span>;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">$$name = <span style="color:#CC0000;">'bar'</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;">echo $foo;</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;">// imprime 'bar' </span></div>
</li>
</ol>
</div>
</div>
</div>
<p></p>
<p>No caso de uma funÃ§Ã£o:</p>
<div class="igBar"><span id="lcode-13"><a href="#" onclick="javascript:showCodeTxt('code-13'); return false;">PLAIN TEXT</a></span></div>
<div class="syntax_hilite"><span class="langName">CODE:</span>
<div id="code-13">
<div class="code">
<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;">function minhaFunc<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:#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; echo <span style="color:#CC0000;">'minhaFunc'</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;">$f = <span style="color:#CC0000;">'minhaFunc'</span>;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">$f<span style="color:#006600; font-weight:bold;">&#40;</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;">// chama a funÃ§Ã£o minhaFunc </span></div>
</li>
</ol>
</div>
</div>
</div>
<p></p>
<h3>Constantes</h3>
<p>Constantes sÃ£o variaveis de valores imutaveis e podem ser acessados de quaquer escopo dentro do PHP, uma boa prÃ¡tica Ã© declar-las somente com letras maiÃºsculas. Veja os exemplos:</p>
<div class="igBar"><span id="lcode-14"><a href="#" onclick="javascript:showCodeTxt('code-14'); return false;">PLAIN TEXT</a></span></div>
<div class="syntax_hilite"><span class="langName">CODE:</span>
<div id="code-14">
<div class="code">
<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;">define<span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#CC0000;">'EMAIL_PADRAO'</span>, <span style="color:#CC0000;">'silici0@gmail.com'</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;">echo EMAIL_PADRAO;</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;">// imprime 'silici0@gmail.com'</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;">if<span style="color:#006600; font-weight:bold;">&#40;</span> EMAIL_PADRAO == <span style="color:#CC0000;">'silici0@gmail.com'</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:#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;<span style="color:#FF9933; font-style:italic;">// Neste caso entra no if (TRUE)</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>
</ol>
</div>
</div>
</div>
<p></p>
<p>Ã‰ isso ae, uma parte do bÃ¡sico esta ae, bom estudos para vocÃªs, espero que pessoal aprenda e utilizem, ainda tem mais bÃ¡sico, mas vamos deixar para um prÃ³ximo post.<!--475e40fbec3c2027acd6345f37fc502b--><!--0f3bb8e180ad4bd83cfd877049c51d7c--><!--650fbffd322cd3f1f5c8c9d6f332cd2a--></p>
]]></content:encoded>
			<wfw:commentRss>http://www.rafaelcunha.com/2008/12/17/php-o-basico/feed/</wfw:commentRss>
		</item>
		<item>
		<title>Layout de diretorios</title>
		<link>http://www.rafaelcunha.com/2008/11/21/layout-de-diretorios/</link>
		<comments>http://www.rafaelcunha.com/2008/11/21/layout-de-diretorios/#comments</comments>
		<pubDate>Fri, 21 Nov 2008 14:02:01 +0000</pubDate>
		<dc:creator>silici0</dc:creator>
		
		<category>Informatica</category>

		<category>php</category>

		<category>Tutorial</category>

		<guid isPermaLink="false">http://www.rafaelcunha.com/2008/11/21/layout-de-diretorios/</guid>
		<description><![CDATA[Bom, eu irei na verdade aqui dar sequencia ao meu modelo de aplicaÃ§Ã£o MVC, se vocÃª nÃ£o conhece pode dar uma lida neste Post, seguindo a ideia vamos agora partir da ideia do layout de diretorios para nossa aplicaÃ§Ã£o, usando Url Amigaveis, primeiro temos que ter em mente que poderemos ter diversos App, ou aplicativos [...]]]></description>
			<content:encoded><![CDATA[<p>Bom, eu irei na verdade aqui dar sequencia ao meu modelo de aplicaÃ§Ã£o MVC, se vocÃª nÃ£o conhece pode dar uma lida neste <a href="http://www.rafaelcunha.com/2008/09/12/mvc-model-view-controller/" >Post</a>, seguindo a ideia vamos agora partir da ideia do layout de diretorios para nossa aplicaÃ§Ã£o, usando Url Amigaveis, primeiro temos que ter em mente que poderemos ter diversos App, ou aplicativos que funcionarÃ£o como modulos (ex: Admin, Cliente, Contas, RH e assim vai) e para cada modulo estarÃ¡ o modelo MVC ( ou MVP ).</p>
<p>Iremos separar tambÃ©m nossas libs (Library ou bibliotecas no bom portuguÃªs), para que possamos atualiza-las independente do sistema (modulos) que tivermos.</p>
<p>Iremos tambÃ©m separar uma pasta chamada var que serÃ£o as variaves do sistema, sÃ£o arquivos que irÃ£o sendo atualizados mudados conforme o tempo de site (no meu caso os templates do smarty e outros arquivos como xml) e iremos separar os arquivos chamados publicos (que sÃ£o aqueles arquivos onde as pessoas podem visualizar e roubar de vocÃª), no caso sÃ£o arquivos JS, CSS, Imagens e coisas do genÃªro.</p>
<p>EntÃ£o por enquanto teremos :</p>
<div class="igBar"><span id="lcode-21"><a href="#" onclick="javascript:showCodeTxt('code-21'); return false;">PLAIN TEXT</a></span></div>
<div class="syntax_hilite"><span class="langName">CODE:</span>
<div id="code-21">
<div class="code">
<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;">/app</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">/lib</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;">/publico</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">/var </div>
</li>
</ol>
</div>
</div>
</div>
<p></p>
<p>Colocando modulos no app e pensando que teremos o modulo rais teremos em MVC a seguinte estrutura :</p>
<div class="igBar"><span id="lcode-22"><a href="#" onclick="javascript:showCodeTxt('code-22'); return false;">PLAIN TEXT</a></span></div>
<div class="syntax_hilite"><span class="langName">CODE:</span>
<div id="code-22">
<div class="code">
<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;">O acesso a estas pastas serÃ¡ travada no .<span style="">htaccess</span> para maior seguranÃ§a</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">/app/</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;">/app/config</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">/app/controller</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;">/app/model</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">/app/view</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;">-----&gt; <span style="">Exemplo</span> modulo Admin</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">/app/Admin</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;">/app/Admin/config</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">/app/Admin/controller</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;">/app/Admin/model</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">/app/Admin/view </div>
</li>
</ol>
</div>
</div>
</div>
<p></p>
<p>No caso ainda no view utilizando um sistema de templates para separar codigo de tela, eu tenho mais duas pastas que irÃ£o separar mais codigo, em vez de construir inputs, selects, e alguns outros na tela com codigo, dou preferencia para buscar uma classe que possa criar para min e eu retornar o codigo pronto para o template, assim separando o que Ã© um codigo contrutor.</p>
<div class="igBar"><span id="lcode-23"><a href="#" onclick="javascript:showCodeTxt('code-23'); return false;">PLAIN TEXT</a></span></div>
<div class="syntax_hilite"><span class="langName">CODE:</span>
<div id="code-23">
<div class="code">
<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;">/app/view/analizador &lt;- arquivos que somente trazem dados para o view</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;">&#40;</span>arquivos so escritos em php, sÃ£o contrutores<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;">/app/view/helpers &lt;- arquivos de carater padrÃ£o entre telas <span style="color:#006600; font-weight:bold;">&#40;</span> topo.<span style="">tpl</span>,</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">banner.<span style="">tpl</span>, menu.<span style="">tpl</span> +++ <span style="color:#006600; font-weight:bold;">&#41;</span> </div>
</li>
</ol>
</div>
</div>
</div>
<p></p>
<p>Pensando agora no resto da estrutra, as bibliotecas ( /lib )  o que iremos ter ? No meu caso eu terei algumas bibliotecas suporte e principalmente aqui uma biblioteca (camada de persistÃªncia - Base de dados), veja como fica:</p>
<div class="igBar"><span id="lcode-24"><a href="#" onclick="javascript:showCodeTxt('code-24'); return false;">PLAIN TEXT</a></span></div>
<div class="syntax_hilite"><span class="langName">CODE:</span>
<div id="code-24">
<div class="code">
<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;">O acesso a estas pastas serÃ¡ travada no .<span style="">htaccess</span> para maior seguranÃ§a</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">/lib/</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;">/lib/commom &lt;-- classes de uso comum durante todo o sistema <span style="color:#006600; font-weight:bold;">&#40;</span>ex. <span style="">classe</span> envioMail<span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#006600; font-weight:bold;">&#41;</span>, Upload<span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#006600; font-weight:bold;">&#41;</span>, Conexao<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-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">/lib/MDB2&nbsp; &lt;--&nbsp; classe camada de persistÃªncia</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;">/lib/smarty</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">/lib/a j a x </div>
</li>
</ol>
</div>
</div>
</div>
<p></p>
<p>O layout da publico Ã© super simples e podemos criar diversas regras no .htaccess para moderamos o uso desta estrutura</p>
<div class="igBar"><span id="lcode-25"><a href="#" onclick="javascript:showCodeTxt('code-25'); return false;">PLAIN TEXT</a></span></div>
<div class="syntax_hilite"><span class="langName">CODE:</span>
<div id="code-25">
<div class="code">
<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;">/publico</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">/publico/images</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;">/publico/scripts</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">/publico/styles </div>
</li>
</ol>
</div>
</div>
</div>
<p></p>
<p>No meu caso a var que contÃ©m os dados de teamplates compilados e cache deles.</p>
<div class="igBar"><span id="lcode-26"><a href="#" onclick="javascript:showCodeTxt('code-26'); return false;">PLAIN TEXT</a></span></div>
<div class="syntax_hilite"><span class="langName">CODE:</span>
<div id="code-26">
<div class="code">
<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;">Estrutura para dados que possam ser alterados, tambÃ©m protegido por htaccess</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">/var </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;">/var/tpl_cache</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">/var/tpl_compiled </div>
</li>
</ol>
</div>
</div>
</div>
<p></p>
<p>Ã‰ isso ai pessoal, logo mais vou continuar escrevendo dos htaccess de cada pasta e do index para nos acessarmos tudo isso com um unico arquivo sÃ³. Ficaria muito grande esse index e access aqui neste mesmo texto, entÃ£o ficamos para a prÃ³xima.<!--5ff37f95cbe7e8990ca47b91d617b8a9--><!--d1aa63a4ff88e74e202024914bb2c5d4--></p>
]]></content:encoded>
			<wfw:commentRss>http://www.rafaelcunha.com/2008/11/21/layout-de-diretorios/feed/</wfw:commentRss>
		</item>
		<item>
		<title>phpConf 2008</title>
		<link>http://www.rafaelcunha.com/2008/11/18/phpconf-2008/</link>
		<comments>http://www.rafaelcunha.com/2008/11/18/phpconf-2008/#comments</comments>
		<pubDate>Tue, 18 Nov 2008 14:30:20 +0000</pubDate>
		<dc:creator>silici0</dc:creator>
		
		<category>Informatica</category>

		<category>Trabalho</category>

		<category>php</category>

		<category>Tutorial</category>

		<guid isPermaLink="false">http://www.rafaelcunha.com/2008/11/18/phpconf-2008/</guid>
		<description><![CDATA[E lÃ¡ vamos nÃ³s, ou melhor dizendo eu, confirmada minha presenÃ§a nos 3 dias da php Conference Brasil 2008, vou deixar aqui a programaÃ§Ã£o que pretendo assistir e participar, espero ver vocÃªs lÃ¡.

Quinta feira :
No perÃ­odo da manhÃ£ vou assitir a palestra/curso sobre SOA com o CÃ©sar Schneider.
No perÃ­odo da tarde irei voltar a trabalhar, [...]]]></description>
			<content:encoded><![CDATA[<p>E lÃ¡ vamos nÃ³s, ou melhor dizendo eu, confirmada minha presenÃ§a nos 3 dias da php Conference Brasil 2008, vou deixar aqui a programaÃ§Ã£o que pretendo assistir e participar, espero ver vocÃªs lÃ¡.</p>
<p><a href="http://www.phpconf.com.br" onclick="javascript:pageTracker._trackPageview('/outbound/article/http://www.phpconf.com.br');"><img src="http://www.phpconf.com.br/includes/templates/padrao/imagens/logo.gif" alt="phpConf" /></a></p>
<p>Quinta feira :</p>
<p>No perÃ­odo da manhÃ£ vou assitir a palestra/curso sobre SOA com o CÃ©sar Schneider.<br />
No perÃ­odo da tarde irei voltar a trabalhar, hehehe.</p>
<p>Sexta-feira :</p>
<p>O que eu gostaria de assistir Ã© "Camadas do desenvolvimento Web", "Vulnerabilidades", "OpenSocial", "SPL", "PHP Doc"... Ã© algumas das palestras que me interessam ainda estou incerto do que irÃ¡ me fazer melhor.</p>
<p>SÃ¡bado :</p>
<p>SÃ¡bado Ã© um grande mistÃ©rio se irei aparecer, ainda mais em relaÃ§Ã£o as palestras, veremos atÃ© la o que irÃ¡ aconteÃ§er.<!--45fdd72f880b5716f4a1e1223bfd4c5e--><!--649c77c57bd01cd202b2339a0839c281--></p>
]]></content:encoded>
			<wfw:commentRss>http://www.rafaelcunha.com/2008/11/18/phpconf-2008/feed/</wfw:commentRss>
		</item>
		<item>
		<title>Namespaces no PHP</title>
		<link>http://www.rafaelcunha.com/2008/11/07/namespaces-no-php/</link>
		<comments>http://www.rafaelcunha.com/2008/11/07/namespaces-no-php/#comments</comments>
		<pubDate>Fri, 07 Nov 2008 15:13:00 +0000</pubDate>
		<dc:creator>silici0</dc:creator>
		
		<category>Informatica</category>

		<category>php</category>

		<category>Tutorial</category>

		<guid isPermaLink="false">http://www.rafaelcunha.com/2008/11/07/namespaces-no-php/</guid>
		<description><![CDATA[Todo mundo vem falando da grande discuÃ§Ã£o do namespace no PHP, ja que vai ser uma caracterÃ­stica nova e nem tudo mundo estÃ¡ acontento do uso ou de como vai ser usado, por isso desta discuÃ§Ã£o enorme, porÃ©m ainda existe muitas pessoas que nem sabe o que Ã© namespace, por isso vou escrever para tirar [...]]]></description>
			<content:encoded><![CDATA[<p>Todo mundo vem falando da grande discuÃ§Ã£o do namespace no PHP, ja que vai ser uma caracterÃ­stica nova e nem tudo mundo estÃ¡ acontento do uso ou de como vai ser usado, por isso desta discuÃ§Ã£o enorme, porÃ©m ainda existe muitas pessoas que nem sabe o que Ã© namespace, por isso vou escrever para tirar as dÃºvidas e para exemplificar seu funcionamento.</p>
<h4>O Porque</h4>
<p>O uso de namespace Ã© bom para evitarmos conflitos com nomes de classes, mÃ©todos e para o uso de classes com nomes gigantes ex: Super_ultra_mega_nome_da_classe_que_faz_algo, surgindo diversas facilidades na hora de usarmos pacotes e incluirmos bibliotecas.</p>
<h4>Antes de tudo</h4>
<p>MÃ©todos estÃ¡ticos, no caso quando se usa mÃ©todos estÃ¡ticos nÃ£o hÃ¡ a necessidade de se instanciar a classe, segue exemplo abaixo</p>
<div class="igBar"><span id="lcode-33"><a href="#" onclick="javascript:showCodeTxt('code-33'); return false;">PLAIN TEXT</a></span></div>
<div class="syntax_hilite"><span class="langName">CODE:</span>
<div id="code-33">
<div class="code">
<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;">class foo <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; public static function bar<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; &nbsp; &nbsp; return true;</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;"><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;</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;">// chamando o mÃ©todo estÃ¡tico</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">$resultado&nbsp; = foo::<span style="">bar</span><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#006600; font-weight:bold;">&#41;</span>; </div>
</li>
</ol>
</div>
</div>
</div>
<p></p>
<h4>A discuÃ§Ã£o</h4>
<p>A grande discuÃ§Ã£o disto tudo foi qual seria o separador do namespace, em muitas <a href="http://phpimpact.wordpress.com/2008/10/28/php-namespaces-controversy/" onclick="javascript:pageTracker._trackPageview('/outbound/article/http://phpimpact.wordpress.com/2008/10/28/php-namespaces-controversy/');">linguagens</a> usa-se o "::" tambÃ©m (alias, mesmo separador que o estÃ¡tico), porem com a chamada em maiÃºscula Foo::bar(), neste caso ele pode ser confundido com um separador para chamadas de mÃ©todos estÃ¡ticos, o que criaria uma confusÃ£o, neste caso entÃ£o rolou uma discuÃ§Ã£o em qual outro separador deveria ser usado, em principio discutiu-se muito o separador ":::" com o separador "\", no caso foi escolhido o \ por diversos motivos, que pode-se ser visto <a href="http://wiki.php.net/rfc/backslashnamespaces" onclick="javascript:pageTracker._trackPageview('/outbound/article/http://wiki.php.net/rfc/backslashnamespaces');">aqui</a>.<br />
Saiba mais sobre a discuÃ§Ã£o <a href="http://www.augustopascutti.com/namespaces" onclick="javascript:pageTracker._trackPageview('/outbound/article/http://www.augustopascutti.com/namespaces');">aqui</a> e <a href="http://www.augustopascutti.com/namespaces-a-revolta-continua" onclick="javascript:pageTracker._trackPageview('/outbound/article/http://www.augustopascutti.com/namespaces-a-revolta-continua');">aqui</a> no blog do Augusto Pascutti.</p>
<h4>Exemplos</h4>
<p>Neste primeiro exemplo vamos lidar com nomes de classes gigantes para vermos como fica com a declaraÃ§Ã£o do namespace:</p>
<p>mysql_base.php</p>
<div class="igBar"><span id="lcode-34"><a href="#" onclick="javascript:showCodeTxt('code-34'); return false;">PLAIN TEXT</a></span></div>
<div class="syntax_hilite"><span class="langName">CODE:</span>
<div id="code-34">
<div class="code">
<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:#FF9933; font-style:italic;">// The class file</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">namespace Mysql\DB;</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;">class Connection_com_mysql_utilizando_foo_printando_bar <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;function foo<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; &nbsp; &nbsp; &nbsp;echo <span style="color:#CC0000;">'bar'</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>
</ol>
</div>
</div>
</div>
<p></p>
<div class="igBar"><span id="lcode-35"><a href="#" onclick="javascript:showCodeTxt('code-35'); return false;">PLAIN TEXT</a></span></div>
<div class="syntax_hilite"><span class="langName">CODE:</span>
<div id="code-35">
<div class="code">
<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;">require <span style="color:#CC0000;">'Lib/DB/mysql_base.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;">use Mysql\DB\Connection_com_mysql_utilizando_foo_printando_bar as DbConnection;</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;">$z = new DbConnection<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;">$z-&gt;<span style="">foo</span><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#006600; font-weight:bold;">&#41;</span>; </div>
</li>
</ol>
</div>
</div>
</div>
<p></p>
<p>Lidando com nomes de classes e metodos que possam surgir com nomes iguais</p>
<p>arquivo1.php</p>
<div class="igBar"><span id="lcode-36"><a href="#" onclick="javascript:showCodeTxt('code-36'); return false;">PLAIN TEXT</a></span></div>
<div class="syntax_hilite"><span class="langName">CODE:</span>
<div id="code-36">
<div class="code">
<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;">namespace foo;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">function bar<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; echo <span style="color:#CC0000;">"funcao<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:#006600; font-weight:bold;">&#125;</span> </div>
</li>
</ol>
</div>
</div>
</div>
<p></p>
<div class="igBar"><span id="lcode-37"><a href="#" onclick="javascript:showCodeTxt('code-37'); return false;">PLAIN TEXT</a></span></div>
<div class="syntax_hilite"><span class="langName">CODE:</span>
<div id="code-37">
<div class="code">
<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;">include <span style="color:#CC0000;">'file1.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;">class foo <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; static function bar<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>echo <span style="color:#CC0000;">"method<span style="color:#000099; font-weight:bold;">\n</span>"</span>;<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:#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;</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;">foo\bar<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;">// O que serÃ¡ impresso ?</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;">// SerÃ¡ impresso o &quot;funcao&quot;, pois estamos chamando apartir do namespace </span></div>
</li>
</ol>
</div>
</div>
</div>
<p></p>
<p>Vamos a outro exemplo simples de como podemos lidar nomes de funÃ§Ãµes/mÃ©todos iguais diante do sistema</p>
<div class="igBar"><span id="lcode-38"><a href="#" onclick="javascript:showCodeTxt('code-38'); return false;">PLAIN TEXT</a></span></div>
<div class="syntax_hilite"><span class="langName">CODE:</span>
<div id="code-38">
<div class="code">
<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;">namespace foo\foo;</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;">function bar<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>echo <span style="color:#CC0000;">"func<span style="color:#000099; font-weight:bold;">\n</span>"</span>;<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;</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;">namespace foo;</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;">class foo <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; static function bar<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>echo <span style="color:#CC0000;">"method<span style="color:#000099; font-weight:bold;">\n</span>"</span>;<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:#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;</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;">foo\bar<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;">// O que sera impresso ?</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;">// SerÃ¡ impresso o &quot;method&quot;, pois estamos chamando apartir do namespace foo\ caso se quisermos a funÃ§Ã£o, usamos foo\foo\bar </span></div>
</li>
</ol>
</div>
</div>
</div>
<p><!--87fdbb5e748b493b48f1d6b8792afb9d--><!--54d9cf694e49e5543b245ecdab74f762--></p>
]]></content:encoded>
			<wfw:commentRss>http://www.rafaelcunha.com/2008/11/07/namespaces-no-php/feed/</wfw:commentRss>
		</item>
		<item>
		<title>Cortar a frase sem cortar palavras</title>
		<link>http://www.rafaelcunha.com/2008/10/20/cortar-a-frase-sem-cortar-palavras/</link>
		<comments>http://www.rafaelcunha.com/2008/10/20/cortar-a-frase-sem-cortar-palavras/#comments</comments>
		<pubDate>Mon, 20 Oct 2008 13:30:46 +0000</pubDate>
		<dc:creator>silici0</dc:creator>
		
		<category>Informatica</category>

		<category>php</category>

		<category>Tutorial</category>

		<guid isPermaLink="false">http://www.rafaelcunha.com/2008/10/20/cortar-a-frase-sem-cortar-palavras/</guid>
		<description><![CDATA[Bom, quando temos que imprimir um texto na tela e temos um espaÃ§o determinado Ã© comum o uso do substr() no PHP para cortarmos somente um pedaÃ§o determinado, porÃ©m com esta funÃ§Ã£o ela ira retornar cortando uma palavra quando a mesma estiver na posiÃ§Ã£o de termino, o que nos gera um problema, vocÃª nÃ£o vai [...]]]></description>
			<content:encoded><![CDATA[<p>Bom, quando temos que imprimir um texto na tela e temos um espaÃ§o determinado Ã© comum o uso do substr() no PHP para cortarmos somente um pedaÃ§o determinado, porÃ©m com esta funÃ§Ã£o ela ira retornar cortando uma palavra quando a mesma estiver na posiÃ§Ã£o de termino, o que nos gera um problema, vocÃª nÃ£o vai querer um texto com uma palavra no final cortada, por isso conversando com o TulioFaria (o que nÃ³s deu uma soluÃ§Ã£o neste <a href="http://www.tuliofaria.net/cortar-frase-sem-cortar-palavras/" onclick="javascript:pageTracker._trackPageview('/outbound/article/http://www.tuliofaria.net/cortar-frase-sem-cortar-palavras/');">post</a>) e com o Reflect que deu a lÃ³gica; pesquisei um pouco no PHP.net e cheguei a uma conclusÃ£o bem bacana.</p>
<p>NÃ³s precisamos cortar o pedaÃ§o e neste pedaÃ§o encontrar a ultima posiÃ§Ã£o do espaÃ§o, depois recortar o nosso texto nesta ultima posiÃ§Ã£o, vamos as funÃ§Ãµes:</p>
<div class="igBar"><span id="lphp-40"><a href="#" onclick="javascript:showCodeTxt('php-40'); return false;">PLAIN TEXT</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:#FF9933; font-style:italic;">// retorna a posiÃ§Ã£o exata do ultimo espaÃ§o dentro do espaÃ§o cortado</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;">// Neste caso dentro dos primeiros 50 caracteres</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;">$valor</span> = <a href="http://www.php.net/strrpos" onclick="javascript:pageTracker._trackPageview('/outbound/article/http://www.php.net/strrpos');"><span style="color:#000066;">strrpos</span></a><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#0000FF;">$string</span>, <span style="color:#FF0000;">" "</span>, -<span style="color:#006600; font-weight:bold;">&#40;</span><a href="http://www.php.net/strlen" onclick="javascript:pageTracker._trackPageview('/outbound/article/http://www.php.net/strlen');"><span style="color:#000066;">strlen</span></a><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#0000FF;">$string</span><span style="color:#006600; font-weight:bold;">&#41;</span> - <span style="color:#CC66CC;color:#800000;">50</span><span style="color:#006600; font-weight:bold;">&#41;</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;">// Basta agora dizermos que queremos da posicao 0 atÃ© o valor retornado</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/substr" onclick="javascript:pageTracker._trackPageview('/outbound/article/http://www.php.net/substr');"><span style="color:#000066;">substr</span></a><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#0000FF;">$string</span>,<span style="color:#CC66CC;color:#800000;">0</span>,<span style="color:#0000FF;">$valor</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:#FF9933; font-style:italic;">// Para imprimir em um texto podemos concatenar tudo, ficando da seguinte maneira</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" onclick="javascript:pageTracker._trackPageview('/outbound/article/http://www.php.net/echo');"><span style="color:#000066;">echo</span></a> <span style="color:#FF0000;">'Texto : '</span>.<a href="http://www.php.net/substr" onclick="javascript:pageTracker._trackPageview('/outbound/article/http://www.php.net/substr');"><span style="color:#000066;">substr</span></a><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#0000FF;">$string</span>,<span style="color:#CC66CC;color:#800000;">0</span>, <a href="http://www.php.net/strrpos" onclick="javascript:pageTracker._trackPageview('/outbound/article/http://www.php.net/strrpos');"><span style="color:#000066;">strrpos</span></a><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#0000FF;">$string</span>, <span style="color:#FF0000;">" "</span>, -<span style="color:#006600; font-weight:bold;">&#40;</span><a href="http://www.php.net/strlen" onclick="javascript:pageTracker._trackPageview('/outbound/article/http://www.php.net/strlen');"><span style="color:#000066;">strlen</span></a><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#0000FF;">$string</span><span style="color:#006600; font-weight:bold;">&#41;</span> - <span style="color:#CC66CC;color:#800000;">50</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;">&#41;</span>.<span style="color:#FF0000;">' ...'</span>; </div>
</li>
</ol>
</div>
</div>
</div>
<p><!--24ba46af0776d72b5d75e130ee651b2e--></p>
]]></content:encoded>
			<wfw:commentRss>http://www.rafaelcunha.com/2008/10/20/cortar-a-frase-sem-cortar-palavras/feed/</wfw:commentRss>
		</item>
		<item>
		<title>Da Query (MySQL) para JSon</title>
		<link>http://www.rafaelcunha.com/2008/10/07/da-query-mysql-para-json/</link>
		<comments>http://www.rafaelcunha.com/2008/10/07/da-query-mysql-para-json/#comments</comments>
		<pubDate>Tue, 07 Oct 2008 20:32:53 +0000</pubDate>
		<dc:creator>silici0</dc:creator>
		
		<category>JavaScript</category>

		<category>AJAX</category>

		<category>Tutorial</category>

		<guid isPermaLink="false">http://www.rafaelcunha.com/2008/10/07/da-query-mysql-para-json/</guid>
		<description><![CDATA[Bom, como jÃ¡ Ã© comum as pessoas trabalharem com AJAX onde o envio se da para um arquivo que se conecta em um banco de dados e retorna o resultado de um Query, vou ensinar como tratar esse(s) dado(s) para retornar um Json e processar os dados sem o uso de eval(), pois como foi [...]]]></description>
			<content:encoded><![CDATA[<p>Bom, como jÃ¡ Ã© comum as pessoas trabalharem com <a href="http://pt.wikipedia.org/wiki/AJAX_%28programa%C3%A7%C3%A3o%29" onclick="javascript:pageTracker._trackPageview('/outbound/article/http://pt.wikipedia.org/wiki/AJAX_%28programa%C3%A7%C3%A3o%29');"  class="alinks_links" onclick="return alinks_click(this);" title="Asynchronous JavaScript and XML"  style="padding-right: 13px; background: url(http://rafaelcunha.com/WordPress/wp-content/plugins/alinks/images/external.png) center right no-repeat;" rel="external">AJAX</a> onde o envio se da para um arquivo que se conecta em um banco de dados e retorna o resultado de um Query, vou ensinar como tratar esse(s) dado(s) para retornar um <a href="http://pt.wikipedia.org/wiki/JSON" onclick="javascript:pageTracker._trackPageview('/outbound/article/http://pt.wikipedia.org/wiki/JSON');"  class="alinks_links" onclick="return alinks_click(this);" title="JavaScript Object Notation"  style="padding-right: 13px; background: url(http://rafaelcunha.com/WordPress/wp-content/plugins/alinks/images/external.png) center right no-repeat;" rel="external">Json</a> e processar os dados sem o uso de eval(), pois como foi comentado no outro <a target="_blank" title="Json populando formulario" href="http://www.rafaelcunha.com/2007/08/28/json-populando-formulario" >post</a> sobre, o eval Ã© uma funÃ§Ã£o perigosa que pode executar cÃ³digos javascript maliciosos, para isso iremos usar um parser (retirado do <a target="_blank" title="Json " href="http://www.rafaelcunha.com/json.org" >Json.org</a>).</p>
<p>Vamos ao que interessa, primeiramente vamos ver como tratar os dados de retorno de uma query, no qual precisamos criar uma array que para cada posiÃ§Ã£o teremos uma array com os valores:</p>
<div class="igBar"><span id="lphp-43"><a href="#" onclick="javascript:showCodeTxt('php-43'); return false;">PLAIN TEXT</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:#0000FF;">$query</span>=<span style="color:#FF0000;">"SELECT * FROM clientes"</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;">$resp</span>=<a href="http://www.php.net/mysql_query" onclick="javascript:pageTracker._trackPageview('/outbound/article/http://www.php.net/mysql_query');"><span style="color:#000066;">mysql_query</span></a><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#0000FF;">$query</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;">$obj</span>=<a href="http://www.php.net/array" onclick="javascript:pageTracker._trackPageview('/outbound/article/http://www.php.net/array');"><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>;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#616100;">while</span><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#0000FF;">$ret</span>=<a href="http://www.php.net/mysql_fetch_assoc" onclick="javascript:pageTracker._trackPageview('/outbound/article/http://www.php.net/mysql_fetch_assoc');"><span style="color:#000066;">mysql_fetch_assoc</span></a><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#0000FF;">$resp</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;"><span style="color:#0000FF;">$obj</span><span style="color:#006600; font-weight:bold;">&#91;</span><span style="color:#006600; font-weight:bold;">&#93;</span> = <span style="color:#0000FF;">$ret</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;"><a href="http://www.php.net/echo" onclick="javascript:pageTracker._trackPageview('/outbound/article/http://www.php.net/echo');"><span style="color:#000066;">echo</span></a> json_encode<span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#0000FF;">$obj</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:#008000;">/*Imaginemos que o Obj tenha o seguinte conteudo:</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;">Array</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;">(</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;">[0] =&gt; Array</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;">(</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;">[id] =&gt; 7</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;">[usuario] =&gt; usuario</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;">[nome] =&gt; Rafael</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;">)</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;">[1] =&gt; Array</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;">(</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;">[id] =&gt; 8</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;">[usuario] =&gt; user</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;">[nome] =&gt; Cunha</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;">)</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;"><span style="color:#008000;">*/</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:#008000;">/*O conteÃºdo do echo serÃ¡</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;">[{&quot;id&quot;:&quot;7&quot;, &quot;usuario&quot;:&quot;usuario&quot;,&quot;nome&quot;:&quot;Rafael&quot; },</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;">{&quot;id&quot;:&quot;8&quot;, &quot;usuario&quot;:&quot;user&quot;,&quot;nome&quot;:&quot;Cunha&quot;}]</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>
</ol>
</div>
</div>
</div>
<p></p>
<p>Acima entÃ£o no final usamos a funÃ§Ã£o json_encode do PHP para passarmos nossa array para um valor representante em Json.<br />
Agora nossa funÃ§Ã£o ajax (javascript) ja recebeu os dados e o que precisamos Ã© dar um parse para passarmos para um Obj com notaÃ§Ã£o Json para podermos manipular os dados livremente, para isso precisaremos do parser que estÃ¡ escrito em JavaScript e pode ser feito o download na pÃ¡gina do Json.org:</p>
<div class="igBar"><span id="ljavascript-44"><a href="#" onclick="javascript:showCodeTxt('javascript-44'); return false;">PLAIN TEXT</a></span></div>
<div class="syntax_hilite"><span class="langName">JAVASCRIPT:</span>
<div id="javascript-44">
<div class="javascript">
<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: #009900; font-style: italic;">// Imaginando que seu Ajax (funÃ§Ã£o) retorne o resultado com o nome de var data</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #003366; font-weight: bold;">var</span> myObject = JSON.<span style="color: #006600;">parse</span><span style="color: #66cc66;">&#40;</span>data<span style="color: #66cc66;">&#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: #009900; font-style: italic;">// Pronto: para acessarmos os dados podemos utilizar o</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #009900; font-style: italic;">// myObject.id</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: #009900; font-style: italic;">// myObject.usuario</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #009900; font-style: italic;">// myObject.nome</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: #009900; font-style: italic;">// For roda o Objeto JSon e retorna valor</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: #000066; font-weight: bold;">for</span> <span style="color: #66cc66;">&#40;</span><span style="color: #003366; font-weight: bold;">var</span> x <span style="color: #000066; font-weight: bold;">in</span> myObject<span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#123;</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #000066;">alert</span><span style="color: #66cc66;">&#40;</span><span style="color: #3366CC;">"Meu id:Â&nbsp; "</span>+myObject<span style="color: #66cc66;">&#91;</span>x<span style="color: #66cc66;">&#93;</span>.<span style="color: #006600;">id</span>+<span style="color: #3366CC;">" usuario : "</span>+myObject<span style="color: #66cc66;">&#91;</span>x<span style="color: #66cc66;">&#93;</span>.<span style="color: #006600;">usuario</span>+<span style="color: #3366CC;">" nome : "</span>+myObject<span style="color: #66cc66;">&#91;</span>x<span style="color: #66cc66;">&#93;</span>.<span style="color: #006600;">nome</span><span style="color: #66cc66;">&#41;</span>;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #66cc66;">&#125;</span> </div>
</li>
</ol>
</div>
</div>
</div>
<p></p>
<p>Poque usar o JSON.parse() ? Na verdade como dito anteriormente Ã© uma questÃ£o de seguranÃ§a, pois este parse nÃ£o executa cÃ³digos, nos livrando de problemas com scripts maliciosos, alÃ©m de ser mais rÃ¡pido do que simplesmente executar um eval(), este parse pode ser usado para executar funÃ§Ãµes em conjunto com a criaÃ§Ã£o do Obj, basta dar uma olhada na documentaÃ§Ã£o.<!--fdfb4d1367bce6e185d970169573e820--><!--ead40fb98c7f239cd5ebc5ea292c9bee--><!--fc8f38d551badb10af6b5b6cf3655107--></p>
]]></content:encoded>
			<wfw:commentRss>http://www.rafaelcunha.com/2008/10/07/da-query-mysql-para-json/feed/</wfw:commentRss>
		</item>
	</channel>
</rss>
