OOP in PHP
Yeah! I know this blog was requested to record my learning in ASP.NET 2.0 and C#. But I'm currently doing OOP in PHP right now and I'm very happy on what I'm learning. Hopefully this helps to newbies like me enjoy OOP and practice it.
ok i've been reading the PHP Manual about OOP in PHP 5 but still I get confused on how will this work on me. I believe that OOP will help in a lot of ways. As of the moment I feel that it does. Everything you will see here are just self study, I hope you understand.

I'm not sure either if my understanding is right or if im doing it correctly. The thing about separation of UI to the presentation logic?
Here's what i'm doing I'm avoiding embedding all PHP codes to my HTML codes. I'm just embedding the include one's.
e.g. portCategory.php
<?php
class portCategory {
//Initialize Variable here.
function portCategory () {
}
function setLink($value) {
$this->LinkURL=$value;
}
function setThumb($value) {
$this->ThumbURL=$value;
}
function setCaption($value) {
$this->Caption=$value;
}
function displayCategory($value) {
echo sprintf (
'
<div id="float">
<a href="%s"><img src="%s" />
<br />
<p>%s</a></p>
</div>
',
$this->LinkURL,
$this->ThumbURL,
$this->Caption);
}
?>
e.g. (Here's what I emebedded along with the HTML Code)
<?phpinclude (
'portCategory.php');
// This contain my Class portCategory. include (
'connectionDB.php');
//My DB Connection.
//Query all data needed from the database.$myQuery =
"SELECT * FROM myTable"$resultMyQuery =
mysql_query($myQuery);
//create While
while ($data = mysql_fetch_array($resultMyQuery, MYSQL_BOTH) {
$portCategory =
new portCategory;
$portCategory
->setThumb($data['ImageURL']);
$portCategory
->setCaption($data['Caption']);
$portcategory
->setLink($data['LinkURL']);
$portCategory
->displayPortCategory();
}
?>