Add exams from exam156 to exam199
This commit is contained in:
22
exam194/constants.php
Normal file
22
exam194/constants.php
Normal file
@@ -0,0 +1,22 @@
|
||||
<?php
|
||||
|
||||
//Area of circle
|
||||
|
||||
class Circle{
|
||||
public const pi = 3.14159265359;
|
||||
|
||||
public function CircleArea($r){
|
||||
return self::pi * $r *$r;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
$area = new Circle;
|
||||
|
||||
echo 'if pi is '.Circle::pi . '<br>';
|
||||
|
||||
|
||||
|
||||
echo 'Area of circle is ' . $area->CircleArea(3);
|
||||
|
||||
?>
|
||||
19
exam194/constructor.php
Normal file
19
exam194/constructor.php
Normal file
@@ -0,0 +1,19 @@
|
||||
<?php
|
||||
|
||||
class Example{
|
||||
|
||||
public function __construct($something)
|
||||
{
|
||||
$this-> SaySomething($something);
|
||||
}
|
||||
|
||||
public function SaySomething($something){
|
||||
echo $something;
|
||||
}
|
||||
}
|
||||
|
||||
$example = new Example('Some text');
|
||||
|
||||
|
||||
|
||||
?>
|
||||
Reference in New Issue
Block a user