Jump to content

Developing first set of classes in PHP OOP


lopes_andre

Recommended Posts

Hi,

 

I'm new to PHP OOP and I'm playing with a test project to put theory in practice.

 

Ok, the goal is to build an "Escorts Ads" website with OOP.

 

My aproach to this problem is this:

 

<?php

class Escorts {

public $name;
public $telephone;
public $birthdate; 
public $height; 
public $weight; 
public $chest; 
public $hair; 
public $eyes; 

public function __construct( $name, $telephone, $birthdate, $height, $weight, $chest, $hair, $eyes ) {
$this->name = $name;
$this->telephone = $telephone;
$this->birthdate = $birthdate;
$this->height = $height;
$this->weight = $weight;
$this->chest = $chest;
$this->hair = $hair;
$thid->eyes = $eyes;
}

function getEscort() {
	// get escort
}

function setEscort() {

}
}


class Ads {

public $title;
public $country; 
public $district; 
public $location; 

function getAd() {
	// get the ad
}

function setAd() {
	// set the ad
}
}


class Escortsads extends Ads {

public $services; 
public $lat; // lat google maps api
public $lng; // lng google maps api

}

?>

 

What do you think of this organization? Follow the OOP rules?

 

I have created the class "Ads" because of reutilization of classes.

 

Another question. In the class "Escorts" wich is the best way to control if the $telephone have 9 numbers, the $birthdate is a date and so on?

 

Best Regards.

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.