Michael,

Getters really only make sense in relation to an object, as you are getting (retrieving) a property of that object. So if you aren't using objects then I wouldn't say you would use getters. If you can post your code, or portions of it, then everyone would have a better idea of exactly what you are trying to achieve and how it might be refactored/improved, or how we can improve our code by copying yours.

Scott

<?php

class myObj
{
private $x;
private $y;

public function getX()
{
if (isset($this->x))
{
return $this->x;
}
else
{
return false;
}
}

public function setX($newX)
{
$this->x = $newX;
}

public function checkStat()
{
// Call another function to run SQL which and set x
// Check X and return the value
return $this->getX();
}

}

?>
On 09/06/2010 7:53 AM, Michael Ryan wrote:
So I understand the concept of a getter, but I'm wondering how to implement
it in PHP. I currently have a status display where I use SQL to access the
i, retrieve a value, and then display a good or bad indication based on the
value. I have several SQL statement groups to do this. Should I have a
section of my PHP code where I get all these different values, and then a
section where I incorporate those values (stored in variables obviously) in
my HTML? What would the HTML look like?

Thanks!

As an Amazon Associate we earn from qualifying purchases.

This thread ...

Replies:

Follow On AppleNews
Return to Archive home page | Return to MIDRANGE.COM home page

This mailing list archive is Copyright 1997-2024 by midrange.com and David Gibbs as a compilation work. Use of the archive is restricted to research of a business or technical nature. Any other uses are prohibited. Full details are available on our policy page. If you have questions about this, please contact [javascript protected email address].

Operating expenses for this site are earned using the Amazon Associate program and Google Adsense.