-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit 140123e
Showing
7 changed files
with
134 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
<?php | ||
class Bicycle | ||
{ | ||
var $brand; | ||
var $model; | ||
var $year; | ||
var $description = "Used Bicycle"; | ||
var $weight_kg = 0.0; | ||
|
||
|
||
function name() | ||
{ | ||
return "{$this->brand}, {$this->model} ({$this->year})"; | ||
} | ||
|
||
function weight_lbs() | ||
{ | ||
return (floatval($this->weight_kg) * 2.2046226218) . " lbs"; | ||
} | ||
|
||
function set_weight_lbs($value) | ||
{ | ||
$this->weight_kg = floatval($value) / 2.2046226218; | ||
} | ||
} | ||
|
||
$bicycle = new Bicycle; | ||
|
||
$bicycle->brand = "new"; | ||
$bicycle->model = "SDN"; | ||
$bicycle->year = 2019; | ||
$bicycle->weight_kg = 75; | ||
|
||
const BR = "<br>"; | ||
|
||
echo "Bicycle Name: {$bicycle->name()}" . BR; | ||
echo "Bicycle Weight (lbs): {$bicycle->weight_lbs()}" . BR; | ||
echo "Bicycle Weight (kg): " . ($bicycle->weight_lbs() / 2.2046226218) . BR; | ||
echo "Bicycle set Weight to 200 lbs: " . ($bicycle->set_weight_lbs(200)) . BR; | ||
echo "Bicycle Weight (lbs): {$bicycle->weight_lbs()}" . BR; | ||
echo "Bicycle Weight (kg): {$bicycle->weight_kg}" . BR; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
<?php | ||
include './Human.php'; | ||
|
||
class Customer extends Human | ||
{ } | ||
|
||
echo "<title>PHP OOP Sandbox </title>"; | ||
const BR = "<br>"; | ||
|
||
|
||
|
||
|
||
|
||
|
||
$kamal = new Customer; | ||
$kamal->frist_name = "Kamal"; | ||
$kamal->second_name = "Farouk"; | ||
$kamal->birth_date['d'] = 23; | ||
$kamal->birth_date['m'] = 7; | ||
$kamal->birth_date['y'] = 1992; | ||
|
||
echo $kamal->full_name() . BR; | ||
|
||
// $omer = new Customer; | ||
// $omer->frist_name = "Omer"; | ||
// $omer->second_name = "Ali"; | ||
// echo $omer->full_name() . BR; | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
<?php | ||
class Human | ||
{ | ||
var $first_name; | ||
var $second_name; | ||
var $birth_date = []; | ||
|
||
function full_name() | ||
{ | ||
return "{$this->frist_name} {$this->second_name}"; | ||
} | ||
|
||
function age() | ||
{ | ||
|
||
return ""; | ||
} | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
<?php | ||
class Product | ||
{ } | ||
const BR = "<br>"; | ||
$tile = new Product; | ||
$facade = new Product; | ||
$classes = ['Product', 'Category', 'product']; | ||
|
||
echo "<title>PHP OOP Sandbox </title>"; | ||
echo get_class($tile) .BR; | ||
|
||
foreach ($classes as $class) { | ||
if (is_a($tile, $class)) { | ||
echo "Tile is a {$class} instance" .BR; | ||
} else { | ||
echo "Tile is not a {$class} instance" .BR; | ||
} | ||
|
||
if (is_a($facade, $class)) { | ||
echo "Facade is a {$class} instance" .BR; | ||
} else { | ||
echo "Facade is not a {$class} instance" .BR; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
<?php | ||
class Student{ | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
<?php | ||
echo "<title>PHP OOP Sandbox </title>"; | ||
echo "<h1> working </h1>"; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
<?php | ||
|
||
class Product | ||
{ } | ||
$classes = get_declared_classes(); | ||
echo "Classes: " . implode(",<br> ", $classes) . "<br>"; | ||
|
||
$class_names = ['Product', 'Category', 'Project', 'product']; | ||
foreach ($class_names as $class_name) { | ||
if (class_exists($class_name)) { | ||
echo "{$class_name} is declared class.<br>"; | ||
} else { | ||
echo "{$class_name} is not declared class.<br>"; | ||
} | ||
} |