Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
58 changes: 58 additions & 0 deletions 17-ClassDogs.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
<?php

Class Dogs {

public string $name = "";
public string $breed = "";
public int $age = 0;

public function __construct ( string $name1, string $breed1, int $age1) {
$this -> name = $name1;
$this -> breed = $breed1;
$this->age = $age1;
}

public function getDogsData() {

$data = "
<h2> Data Dogs </h2>
Name : {$this->name}<br>
Breed : {$this ->breed}<br>
Age : {$this->age}<br>
";
return $data;
}
}

/* 3 methods Formats !!!


public function setName () {
return $this -> name;
}

public function getName ($name) {
$this -> name = $name;
return $this -> name;
}

public function setBreed () {
return $this -> breed;
}

public function getBreed ($breed) {
$this -> breed = $breed;
return $this;
}

public function setAge () {
return $this -> age;
}

public function getAge ($age) {
$this -> age = $age;
return $this;
} */


?>
35 changes: 35 additions & 0 deletions 18-ClassDogs2.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
<?php

class Dogs2 extends Dogs {

public string $type = "";

public string $firstName = "";

public function __construct (string $name1, string $firstName, string $breed1, int $age1, string $type1) {
$this-> name = $name1;
$this -> firstName = $firstName;
$this -> breed = $breed1;
$this-> age = $age1;
$this -> type = $type1;
}

public function __destruct() {
echo "This properties get deleted: ".$this-> name;
}

public function getDogsData1() {

$data1 = "
<h2> Data Dogs 2 </h2>
Name : {$this->name}<br>
First Name : {$this->firstName}<br>
Breed : {$this ->breed}<br>
Age : {$this->age}<br>
Type : {$this->type}<br><br>
";
return $data1;
}
}

?>
19 changes: 19 additions & 0 deletions 19-indexdogs.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
<?php

require_once("ClassDogs.php");

$dog1 = new Dogs("Max", "Bulldog", 10);

$pet1 = $dog1->getDogsData();

echo $pet1;

require_once("ClassDogs2.php");

$dog2 = new Dogs2( "Maxi", "Max", "Bulldog", 10, "Dog");

$pet2 = $dog2->getDogsData1();

echo $pet2;

?>
25 changes: 25 additions & 0 deletions 20-ClassAbstract.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
<?php

require_once("ClassInterface.php");
abstract class Animals {

public string $name = "";
public int $age = 0;

public function __construct(string $name, int $age) {
$this-> name = $name;
$this->age = $age;
}

public function getAnimalsData() {

$data = "
<h2>Animals Data</h2>
Name : {$this->name}<br>
Age : {$this->age}
";
return $data;
}
}

?>
12 changes: 12 additions & 0 deletions 21-ClassInterface.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
<?php

require_once("ClassAbstract.php");

interface Pets {

public function getAnimalsData();

}


?>
13 changes: 13 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -134,3 +134,16 @@ Namespaces are qualifiers that solve two different problems:
2. They allow the same name to be used for more than one class

In this file you will learn how to create and use namespaces.

### [17 - ClassDogs](17-ClassDogs.php) <!-- omit in toc -->

### [18 - ClassDogs2](18-ClassDogs2.php) <!-- omit in toc -->

### [19 - IndexDogs](19-IndexDogs.php) <!-- omit in toc -->

### [20 - Abstract](20-ClassAbstract.php) <!-- omit in toc -->

### [21 - Interface](21-ClassInterface.php) <!-- omit in toc -->


These Basics seemed simple but nothing beyond reality, when documenting you see that the methods can be developed in different ways and I commented on one of them because I did not know which one was correct, although the result is the same. For the rest it contains many very interesting sections.