I am trying to get a handle of OOP using PHP but I am currently stuck and would like some secondary eyes on this. Basically, I am creating an html background randomization script, I have all my objects ready but getting them to work together using an Ajax call is a different story.
When the success method is called back, it only returns 12. What's wrong with RandomImage.php that is causing it too break?
Step 1. Setup my Ajax call using jQuery
$(document).ready(function(){
$.ajax({
type: "POST",
url: "scripts/getRandomTile.php",
data: "path=http://localhost:8888/otc.ca/media/images/patterns",
success: function(data){
$("body").append("<p>data: " + data + "</p>");
}
});
});
getRandtomTile.php
include_once("http://localhost:8888/lib/classes/php/utils/web/html/RandomImage.php");
echo "1";
echo "2";
$img = new RandomImage();
echo "3";
RandomImage.php
include_once("http://localhost:8888/lib/classes/php/utils/system/openDir.php");
class RandomImage
{
var $images;
var $name = "marlon";
function getImages ($folder_path)
{
$opendir = new openDir();
$opendir->setpath($folder_path);
$this->images = $opendir->getfiles();
}
function getImage()
{
//array_rand($this->images, 1);
return $this->images[0];
}
}