<?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>ZonaPHP &#187; Prog. Orientada a Objetos</title>
	<atom:link href="http://www.zonaphp.com/categorias/prog-orientada-a-objetos/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.zonaphp.com</link>
	<description>No solo un blog, sino toda la información sobre PHP</description>
	<lastBuildDate>Tue, 27 Apr 2010 15:12:37 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.9.2</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>Programación Orientada a Objetos en PHP</title>
		<link>http://www.zonaphp.com/programacion-orientada-a-objetos-en-php/</link>
		<comments>http://www.zonaphp.com/programacion-orientada-a-objetos-en-php/#comments</comments>
		<pubDate>Mon, 24 Feb 2003 17:36:36 +0000</pubDate>
		<dc:creator>Webstudio</dc:creator>
				<category><![CDATA[Prog. Orientada a Objetos]]></category>

		<guid isPermaLink="false">http://www.zonaphp.com/programacion-orientada-a-obprogramacion-orientada-a-objetos-en-phpjetos-en-php/</guid>
		<description><![CDATA[Este artículo escrito originalmente por <strong>Luis Argerich</strong> nos introducirá a la <strong>Programación Orientada a Objetos</strong> (POO o su versión inglesa: OOP) en PHP. En él veremos la forma de programar menos y mejor usando conceptos de <strong>POO</strong> junto con algunos trucos de PHP.]]></description>
			<content:encoded><![CDATA[<p>Este artículo escrito originalmente por <strong>Luis Argerich</strong> nos introducirá a la <strong>Programación Orientada a Objetos</strong> (POO o su versión inglesa: OOP) en PHP. En él veremos la forma de programar menos y mejor usando conceptos de <strong>POO</strong> junto con algunos trucos de PHP.<span id="more-11"></span></p>
<p><strong>Programación Orientada a Objetos en PHP</strong></p>
<p>Algunos "puristas" afirmarán que PHP no es un verdadero lenguaje orienteado a objetos, lo que es cierto. PHP es un lenguaje híbrido dónde se pueden utilizar POO y programación estructurada tradicional. Pero para ciertos proyectos grandes, quizas deseemos/necesitemos(?) usar POO "pura" en PHP, declarando Clases y solo utilizando Objetos y Clases para el proyecto. Mientras emergen dia a dia proyectos más y más grandes, el uso de POO puede ayudar, el código POO es fácil de mantener, facíl de comprender y fácil de reusar. Y estos son los principios de la Ingeniería de Software. Aplicar estos conceptos en proyectos basados en la web, es la clave para el éxito de futurios sitios web.</p>
<p>Este artículo es una introducción a la <strong>Programación Orientada a Objetos</strong> en PHP. Intentaremos mostrarles como se puede programar menos y mejor utilizando algunos conceptos de <strong>POO</strong> y trucos de PHP. Buena Suerte !</p>
<p>Conceptos de programación orientada a objetos: aunque existen diferencias entre distintos autores, puedo decirles que un lenguaje de <strong>POO</strong> debe poseer:</p>
<ul>
<li><strong>Tipos Abstractos de Datos y ocultamiento de la Información</strong></li>
<li><strong>Herencia</strong></li>
<li><strong>Polimorfismo</strong></li>
</ul>
<p>El encapsulamiento en PHP se logra utilizando clases:</p>
<div class="igBar"><a href="javascript:showCodeTxt('php-1');">PLAIN TEXT</a></div>
<div class="syntax_hilite"><span style="color:#000000; font-weight:bold;">PHP:</span>
<div id="php-1">
<div class="php">
<ol>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="color:#000000; 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="color:#000000; font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#000000; font-weight:bold;">class</span> Algo </div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="color:#000000; font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#006600; font-weight:bold;">&#123;</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="color:#000000; font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp;<span style="color:#FF9933; font-style:italic;">// En PHP, las clases usualmente se nombran con la primera letra en mayúscula.</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="color:#000000; font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp;<span style="color:#000000; font-weight:bold;">var</span> <span style="color:#0000FF;">$x</span>;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="color:#000000; 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="color:#000000; font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color:#000000; font-weight:bold;">function</span> setX<span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#0000FF;">$v</span><span style="color:#006600; font-weight:bold;">&#41;</span> </div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="color:#000000; font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &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="color:#000000; font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color:#FF9933; font-style:italic;">// Los Métodos comienzan en minúscula y luego se usan mayúsculas para</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="color:#000000; font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color:#FF9933; font-style:italic;">// separar palabras en el nombre del método.</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="color:#000000; font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color:#FF9933; font-style:italic;">// Ejemplo : obtenerRaizCuadrada();</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="color:#000000; font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color:#0000FF;">$this</span>-&gt;<span style="color:#006600;">x</span> = <span style="color:#0000FF;">$v</span>;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="color:#000000; 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="color:#000000; 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="color:#000000; font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color:#000000; font-weight:bold;">function</span> getX<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="color:#000000; font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &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="color:#000000; font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color:#616100;">return</span> <span style="color:#0000FF;">$this</span>-&gt;<span style="color:#006600;">x</span>;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="color:#000000; 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="color:#000000; 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="color:#000000; 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>Por supuesto, cada uno puede utilizar la nomenclatura que desee, pero utilizar una estandarizada es útil.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.zonaphp.com/programacion-orientada-a-objetos-en-php/feed/</wfw:commentRss>
		<slash:comments>54</slash:comments>
		</item>
	</channel>
</rss>
