Jump to content

Help with basic Class/public property access


Integralist

Recommended Posts

Hello, I'm new to PHP and wanted to write a Class that searched a directory looking for images and then displayed them on a web page at a specific size and a set number of images per page (with next and prev buttons) - ON A SIDE NOTE IF ANYONE KNOWS HOW TO DO THIS THEN CAN THEY HELP.

 

So I started with a simple Class (see code below) but for some odd reason I cannot access the private member properties?

 

Any help appreciated!

 

M.

class ClassGallery {
   // Private Properties
   private $directory = 'test';
   private $imagesPerPage = 10;

   public function _construct($dir, $count)
   {
      // $directory = $dir;
      // $imagesPerPage = $count;
   }

   public function display()
   {
      echo($directory . ' / ' . $imagesPerPage);
   }
}

 

I'm using this code on the front-end page

 

<?php
         include('Class.Gallery.php');
         $gallery = new ClassGallery('images', 20);
         $gallery->display();
      ?>

 

 

 

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.