PHP Module - Variable Wont Set

I'm pretty newish to modular programming.

I'm having trouble setting a variable in a module, but only in particular functions.

I have (useless stuff removed):

class Products extends Modules {

  private $resultsFound;

  function __construct() {

  public function getResultsFound() {
    return $this->resultsFound;

  private function setResultsFound($resultsFound) {
    $this->resultsFound = $resultsFound;


I have 2 public functions in the module, both do near enough the same thing, but one will set the var with $this->setResultsFound(12) and one won't.

public function sortSearchBar($categoryID, $brandID, $sort = false, $limit = false, $search = false){
    foreach ($this->sortAwway as $key => $val) {
        $optionItems[] = '<option value="'.$key.'"'. (($sort == $key) ? ' selected="selected"' : '' ) .'>'.$this->htmlspecialchars($val).'</option>';

    foreach ($this->searchLimit as $key => $val) {
        $limitItems[] = '<option value="'.$key.'"'. (($limit == $key) ? ' selected="selected"' : '' ) .'>'.$this->htmlspecialchars($val).'</option>';
    $this->setResultsFound(12); //works

    return '
    <form action=...

public function showProductItemList($categoryID, $brandID = false, $page, $sort = false, $limit = false, $search = false, $cleanURL = true){

    //echo $this->echoArray($this->getProductsForCategory($categoryID, $brandID));
    $q = $this->getProductsForCategory($categoryID, $brandID, $sort, $search);

    $this->setResultsFound(12); //doesn't work

    return $this->formatProductResults($q, $limit, $cleanURL, $page);

Does anyone have any idea why?

Cheers, Rhys


Reading between the lines, I think that the setResultsFound() method should probably be declared protected, not private.

Read this.

Need Your Help

jQuery .getJSON failing, syntax error?

javascript jquery json syntax-error getjson

I'm trying to parse a JSON file containing some simple key words. My function is not running. Looking at the jQuery .getJSON documentation, I realized that the most likely explanation is a syntax e...

Using customised bootstrap framework

css twitter-bootstrap

I downloaded a customized bootstrap CSS framework from this link

Mysql optimization for REGEXP

mysql regex optimization indexing query-optimization

This query (with different name instead of "jack") happens many times in my slow query log. Why?

About UNIX Resources Network

Original, collect and organize Developers related documents, information and materials, contains jQuery, Html, CSS, MySQL, .NET, ASP.NET, SQL, objective-c, iPhone, Ruby on Rails, C, SQL Server, Ruby, Arrays, Regex, ASP.NET MVC, WPF, XML, Ajax, DataBase, and so on.