I've had a look through several of the related questions and just can't seem to see the issue!
the following two functions are within my function include file and for some reason I cannot seem to get the check_orientation function to return scale to the display_months_news function.
I'm fairly sure I'm just missing something really obviously.
the display_news function
function display_months_news()
{
//header('Content-type: image/jpeg');
$year = date("y");
$year = "20" .$year;
$month = date("m");
if ($month) {
switch ($month){
case "01": $month = "January"; break;
case "02": $month = "February"; break;
case "03": $month = "March"; break;
case "04": $month = "April"; break;
case "05": $month = "May"; break;
case "06": $month = "June"; break;
case "07": $month = "July"; break;
case "08": $month = "August"; break;
case "09": $month = "September"; break;
case "10": $month = "October"; break;
case "11": $month = "November"; break;
case "12": $month = "December"; break;
}
} else {
echo '<p>The date field is empty.</p>';
}
$nowdate = $month." ".$year;
$result = mysql_query("SELECT * FROM news ORDER BY sqldate DESC LIMIT 6") or die(mysql_error());
while ($row = mysql_fetch_array($result)) {
global $imgurl;
$imgurl = $row['img1'];
check_orientation4($imgurl);
$comcount = comment_count($row['nid']);
if ($comcount == NULL) {$comcount = 0;}
echo '<div class="news-preview-container">';
echo '<div class="news-preview-container-date">';
echo "<P>" .$row['mmonth']. " ".$row['dday']. ", " .$row['yyear']. "</p><BR>";
echo '</div>';
echo '<div class="news-preview-container-title">';
echo "<p><a href='article.php?id=" .$row['nid']."'>" .$row['title']."</a></p><BR>";
echo '</div>';
echo '<div class="news-preview-container-inner">';
echo '<div class="news-preview-container-text">';
echo '<p>'.ShortenText($row['body']).'</p>';
echo '</div>';
echo '<div class="news-preview-container-image"><img src="'.$imgurl.'"'.$scale.'"></div><BR></div>';
echo '<div class="news-preview-container-bottombar">Posted in '.$row[tag].' / '.$comcount.' Comments</div>';
echo '</div>';
}
}
and the check_orientation function
function check_orientation4($imgurls){
if ($imgurls == NULL){ echo ""; }
else {
$imgurlshrunk = NULL;
$maxsize = 120;
$filename = NULL;
$height = NULL;
$width = NULL;
$scale = NULL;
$imgurlshrunk = $imgurls;
$filename = basename($imgurlshrunk);
$filename = "admin/uploads/" . $filename;
list($width,$height,$type,$attr) = getimagesize("$filename");
$wRatio = $maxsize / $width;
$hRatio= $maxsize / $height;
global $scale;
if ( ($width <= $maxsize) && ($height <= $maxsize))
{
$scale = "";
return $scale;
}
elseif ( ($wRatio * $height) < $maxsize)
{
$scale = "width = '100%'";
return $scale;
}
elseif ($height == NULL)
{
echo "empty height";
}
else
{
global $height;
$scale = "height = '100%'";
return $scale;
} }}
Thanks in advance to whoever points out the silly mistake i'm missing!
You don't store the result of check_orientation4($imgurl); anywhere. Try changing that line to this:
$scale = check_orientation4($imgurl);
You aren't doing anything with the return value of check_orientation4
You're not assigning the return value of check_orientation4 to anything.
check_orientation4($imgurl);
should be
$scale = check_orientation4($imgurl);
Shouldn't you be returning scale into a variable of some kind? Right now you're just running the function. You should do something like:
$toScale = check_orientation4($imgurl);
Because you're discarding the return value from check_orientation4, perhaps?
Related
I am trying to insert data into database by checking the days in a week but I am unable to insert if I check only one day in a week, if I check two or more days I am able to insert.
<?php
//other parameters
$days_only = $_REQUEST['days_only'];
using an array to split days in a week
$day_array = explode(",",$days_only);
$count_sample = count($day_array);
if($count_sample==1) {
$in_sample='('.$days_only.')';
}
elseif($count_sample>0) {
$in_sample="('".str_replace(",","','" , $days_only)."')";
}
$test='IN'.$in_sample;
$sth = "SELECT e_id FROM `schedule` WHERE
user_id = '$user_id' AND
date BETWEEN '$start_date' AND '$end_date' AND
(
TIME(start_time) >= '$start_time' AND
TIME(start_time) <= '$end_time' OR
TIME(end_time) >= '$start_time' AND
TIME(end_time) <= '$end_time'
) AND days_only $test";
$res = $db->prepare($sth);
$res->execute();
$count = $res->fetchAll();
if ($count) {
echo "すでにスケジュールが登録されています";
} else {
for($i = strtotime($start_date); $i <= strtotime($end_date); $i +=86400 ){
$date = date("Y-m-d", $i);
$days_only = date('l', $i);
switch ($days_only) {
case 'Monday': $days_only = "月"; break;
case 'Tuesday': $days_only = "火"; break;
case 'Wednesday': $days_only = "水"; break;
case 'Thursday': $days_only = "木"; break;
case 'Friday': $days_only = "金"; break;
case 'Saturday': $days_only = "土"; break;
case 'Sunday': $days_only = "日"; break;
}
echo "$date";
echo "$days_only";
if (in_array($days_only,$day_array)){
query for inserting into database
}
else{
echo "wrong";
}
}
}
?>
Here's the issue:
if( $count_sample==1 ) {
$in_sample='('.$days_only.')';
}
The string that you're passing in $days_only is not being escaped here, but it is when the $count_sample value is greater than one. The above code will give you something like this: (金)
Perhaps you can replace the two outermost single-quotes with a double-quote and drop the concat period:
$in_sample= "('$days_only')";
Or you can replace a good bit of code with a single implode():
if ( $count_sample > 0) {
$in_sample="('" . implode("','", $days_only) . "')";
}
Be sure to remember to add validation to your inputs before sending this to the database, otherwise you leave yourself open to SQL injection 👍🏻
I have a problem with correctly generating the days of the month, e.g. from 2018-10-01 to 2018-10-31 and checking if every day generated in the "for" loop is in the MySql database.
I can generate days but during the condition of date comparison from the generated loop with data from the database it displays only records from the database and how it needs to insert empty in the blank records Add date to create errors.
my code :
$conn = dbManager::getConnection();
$tr = 1;
for($tr; $tr < $day; $tr++){
$dt = new DateTime($start);
$msc = $dt->format('m');
switch ($msc) {
case '1':
$m = '1';
break;
case '2':
$m = '2';
break;
case '3':
$m = '3';
break;
case '4':
$m = '4';
break;
case '5':
$m = '5';
break;
case '6':
$m = '6';
break;
case '7':
$m = '7';
break;
case '8':
$m = '8';
break;
case '9':
$m = '9';
break;
case '10':
$m = '10';
break;
case '11':
$m = '11';
break;
case '12':
$m = '12';
break;
}
if($m < 10){
$mc = '0'.$m;
}else{
$mc = $m;
}
if($tr < 10){
$tr = '0'.$tr;
}else{
$tr = $tr;
}
$data = date('Y-'.$mc.'-'.$tr);
echo "<tr><td>".$data."</td><td style='vertical-align:middle;'>";
$result = $conn->query("SELECT * FROM open ")or die(mysqli_error());
while($row = mysqli_fetch_array($result)){
$Start = $row['Start'];
$End = $row['End'];
$dtb = new DateTime($Start);
$dtb_e = new DateTime($End);
$dtb_e->add(new DateInterval('PT1H'));
$w= $dtb->format('Y-m-d');
$ts = $dtb->format('H');
$te = $dtb_e->format('H');
if($w == $data){
for($h=1;$h<24;$h++){
if($h >= $ts && $h <= $te){
if($w < date('Y-m-d')){
$color ='gray';
}else{
$color = 'green';
}
echo '<p style="display:inline;padding:5px; border:1px solid ;background:'.$color.';color:#fff;border-radius: 5px;margin-right:5px;">'.$h.':00</p>';
}else{
$color = 'gray';
echo '<p style="display:inline;padding:5px; border:1px solid ;background:'.$color.';color:#fff;border-radius: 5px;margin-right:5px;">'.$h.':00</p>';
}
}
if($data >= date('Y-m-d')){
echo '<div style="display:inline;text-align:rigth;margin-left:35px;"><a class="btn btn-sm btn-success" href="edit_termin.php?Start='.$row['Start'].'&End='.$row['End'].'&ID='.$row['ID'].'" role="button">Edytuj</a><a class="btn btn-sm btn-danger" href="del_open.php?Start='.$row['Start'].'&End='.$row['End'].'&ID='.$row['ID'].'" role="button">Usuń</a></div>';
}else{
echo '<div style="display:inline;text-align:rigth;margin-left:35px;"><a class="btn btn-sm btn-success disabled" href="edit_termin.php?Start='.$row['Start'].'&End='.$row['End'].'&ID='.$row['ID'].'" role="button">Edytuj</a><a class="btn btn-sm btn-danger disabled" href="del_open.php?Start='.$row['Start'].'&End='.$row['End'].'&ID='.$row['ID'].'" role="button">Usuń</a></div>';
}
if($data != $data){
$dodaj = '<div style="display:inline;text-align:rigth;margin-left:35px;"><a class="btn btn-sm btn-success" href="edit_termin.php?Start='.$data.'" role="button">Dodaj</a></div>';
echo $dodaj;
}else{
echo 'x';
}
}else{
if($data != $data){
$dodaj = '<div style="display:inline;text-align:rigth;margin-left:35px;"><a class="btn btn-sm btn-success" href="edit_termin.php?Start='.$data.'" role="button">Dodaj</a></div>';
echo $dodaj;
}else{
echo 'x';
}
echo '<div style="display:inline;text-align:rigth;margin-left:35px;"><a class="btn btn-sm btn-success" href="edit_termin.php?Start='.$data.'" role="button">Dodaj</a></div>';
}
}
}
echo "</td></tr>";
below result:
generated days without a button add
msg thanks for the help. I modified it according to your hints and works showing the button in the right place but it takes only the hours from the database fields from the last record. :( np.Start 2018-10-05 09:00 End 2018-10-05 20:00) script shows only these hours for each record found in the database and not those hours that are assigned to a given date .. Where can I make a mistake ?
$tr=1;
for($tr; $tr < $day; $tr++){
$dt = new DateTime($start);
$msc = $dt->format('m');
switch ($msc) {
case '1':
$m = '1';
break;
case '2':
$m = '2';
break;
case '3':
$m = '3';
break;
case '4':
$m = '4';
break;
case '5':
$m = '5';
break;
case '6':
$m = '6';
break;
case '7':
$m = '7';
break;
case '8':
$m = '8';
break;
case '9':
$m = '9';
break;
case '10':
$m = '10';
break;
case '11':
$m = '11';
break;
case '12':
$m = '12';
break;
}
if($m < 10){
$mc = '0'.$m;
}else{
$mc = $m;
}
if($tr < 10){
$tr = '0'.$tr;
}else{
$tr = $tr;
}
//$dt = new DateTime($start);
//$msc = $dt->format('m');
// $mc = $nsc; //strpad($msc, 2, '0');
//strpad($tr, 2, '0');
$data = date('Y-'.$mc.'-'.$tr);
echo '<tr><td>'.$data.'</td><td>';
// You should limit your results to the working month
$result = $conn->query("SELECT * FROM open ".$month." ")or die(mysqli_error());
$rows = mysqli_fetch_all($result, MYSQLI_ASSOC);
$db_dates = array_column($rows, 'Start');
$db_dates = array_map(function($data) {
$d = new DateTime($data);
return $d->format('Y-m-d');
}, $db_dates);
// Check if current date is not in the db result
$target_date = array_search($data, $db_dates);
if ($target_date !== FALSE) {
// Add your buttons
foreach ($rows as $key) {
$Start = $key['Start'];
$End = $key['End'];
$id = $key['ID'];
}
$str = $key['Start'];
$ed = $key['End'];
$dtb = new DateTime($str);
$dtb_e = new DateTime($ed);
$dtb_e->add(new DateInterval('PT1H'));
$w= $dtb->format('Y-m-d');
$ts = $dtb->format('H');
$te = $dtb_e->format('H');
for($h=1;$h<24;$h++){
if($h >= $ts && $h <= $te){
if($w < date('Y-m-d')){
$color ='gray';
}else{
$color = 'green';
}
echo '<p style="display:inline;padding:5px; border:1px solid ;background:'.$color.';color:#fff;border-radius: 5px;margin-right:5px;">'.$h.':00</p>';
}else{
$color = 'gray';
echo '<p style="display:inline;padding:5px; border:1px solid ;background:'.$color.';color:#fff;border-radius: 5px;margin-right:5px;">'.$h.':00</p>';
}
}
//--------------------------------------
if($data >= date('Y-m-d')){
//-------------------------
$dst = $data.' '.$ts.':00';
$den = $data.' '.$te.':00';
//echo "SELECT * FROM open WHERE Start >= '".$dst."' AND End <= '".$den."' ";
$res = $conn->query("SELECT * FROM open WHERE Start >= '".$dst."' AND End <= '".$den."' ");
while($r = mysqli_fetch_array($res)){
$idr = $r['ID']; //ID record
echo '<td><div style="display:inline;text-align:rigth;margin-left:35px;"><a class="btn btn-sm btn-success" href="edit_termin.php?Start='.$dst.'&End='.$den.'&ID='.$idr.'" role="button">Edutuj</a><a class="btn btn-sm btn-danger" href="del_open.php?Start='.$dst.'&End='.$den.'&ID='.$idr.'" role="button">Usuń</a></div></td>';
}
}else{
echo '<td><div style="display:inline;text-align:rigth;margin-left:35px;"><a class="btn btn-sm btn-success disabled" href="edit_termin.php?Start='.$row['Start'].'&End='.$row['End'].'&ID='.$idr.'" role="button">Edytuj</a><a class="btn btn-sm btn-danger disabled" href="del_open.php?Start='.$row['Start'].'&End='.$row['End'].'&ID='.$row['ID'].'" role="button">Usuń</a></div></td>';
}
} else {
// Column and map operations keep the indexes, access your record
$row = $rows[$target_date];
// Rest of your logic in here
if($data >= date('Y-m-d')){
echo '<td><div style="display:inline;text-align:rigth;margin-left:35px;"><a class="btn btn-sm btn-success" href="form_terminarz.php?Start='.$data.'" role="button">Dodaj termin</a></div></td>';
}else{
echo '<td><div style="display:inline;text-align:rigth;margin-left:35px;"><a class="btn btn-sm btn-success disabled" href="form_terminarz.php?Start='.$data.'" role="button">Dodaj termin</a></div></td>';
}
}
echo '<td></tr>';
}
Hopefully this will get you going. The idea is to fetch all the results at once so you are able to check if the date is already in the database or not:
$conn = dbManager::getConnection();
$tr = 1;
$dt = new DateTime();
$msc = $dt->format('m');
$mc = str_pad($msc, 2, '0', STR_PAD_LEFT);
// You should limit your results to the working month
$result = $conn->query("SELECT * FROM open ")or die(mysqli_error());
$rows = mysqli_fetch_all($result, MYSQLI_ASSOC);
$db_dates = array_column($rows, 'Start');
$db_dates = array_map(function($v) {
$d = new DateTime($v);
return $d->format('Y-m-d');
}, $db_dates);
for($tr; $tr < $day; $tr++){
$tr = str_pad($tr, 2, '0', STR_PAD_LEFT);
$data = date('Y-'.$mc.'-'.$tr);
// Check if current date is not in the db result
$target_date = array_search($data, $db_dates);
if ($target_date === FALSE) {
// Add your buttons
} else {
// Column and map operations keep the indexes, access your record
$row = $rows[$target_date];
// Rest of your logic in here
}
}
I need a little helping hand in my script. As the title suggests it's about parameters. I have this code:
if (isset($_GET['sendit'])) {
$theusersname = $_GET['theusersname'];
$totalmarks = $_GET['totalmarks'];
$mathsobt = $_GET['mathsobt'];
$physicsobt = $_GET['physicsobt'];
$chemistryobt = $_GET['chemistryobt'];
$computerobt = $_GET['computerobt'];
$englishobt = $_GET['englishobt'];
$totalobt = $mathsobt + $physicsobt + $chemistryobt + $computerobt + $englishobt;
$modulo = ($totalobt / $totalmarks) * 100;
$grade = "";
//for grades
switch ($modulo, $grade) {
case 'A-1'://100% ro 80%
if ($modulo >= 79.5 && $modulo <= 100){
$grade = "A-1";
}
break;
case 'A'://79% to 70%
if ($modulo >= 69.5 && $modulo <= 79.4) {
$grade = "A";
}
break;
case 'B'://69 to 60
if ($modulo >= 59.5 && $modulo <= 69.4){
$grade = "B";
}
break;
case 'C'://59 to 50
if ($modulo >= 49.5 && $modulo <= 59.4){
$grade = "C";
}
break;
case 'D'://49 to 40
if ($modulo >= 39.5 && $modulo <= 49.4){
$grade = "D";
}
break;
case 'F'://32 to rest
if ($modulo >= 33 && $modulo <= 39.4){
$grade = "F";
}
default:
if ($modulo >= 0 && $modulo <= 32.9){
$grade = "N/A";
}
break;
}
//for remarks
switch ($grade) {
case '':
break;
default:
break;
}
$query = "INSERT INTO `report`(`name`, `grade`, `total`, `mathsobt`, `physicsobt`, `chemistryobt`, `computerobt`, `englishobt`, `totalobt`, `modulo`, `remarks`) VALUES ('$theusersname', '$grade', '$totalmarks', '$mathsobt', '$physicsobt', '$chemistryobt', '$computerobt', '$englishobt', '$totalobt', '$modulo', '$remarks')";
$result = mysqli_query($mysqliConn, $query);
// if (mysqli_query($mysqliConn, $query)) {
// echo "New record created successfully";
// } else {
// echo "Error: " . $query . "<br>" . mysqli_error($mysqliConn);
$mysqliConn->close();
// }
The grading switch statement doesn't work. Because I just can't get what parameter I need to give. Same goes for the remarks too. The code may be terrible and don't have sanitization (which in this case I don't need). I'm also a little bit confuse with the strings I passed for cases. I mean does it have an effect on overall?
Thank you.
PS: If there is already a similar answer out there, which i unfortunately i didn't find, i'm ready to view the link. Please post a little explanatory comment.
$modulo && $grade is a boolean expression. Its value is either TRUE or FALSE (and not 'A', 'B' or 'C').
But PHP is a loose-type language and it changes the types of its values as needed before using them. Because of this, 'A' == TRUE and '' == FALSE and your code produces only 'A-1' and 'N/A' grades.
A switch doesn't help here. You should use a sequence of cascaded ifs:
if ($modulo >= 79.5) {
$grade = "A-1";
} elseif ($modulo >= 69.5) {
$grade = "A";
} elseif ($modulo >= 59.5) {
$grade = "B";
} elseif ($modulo >= 49.5) {
$grade = "C";
} elseif ($modulo >= 39.5) {
$grade = "D";
} elseif ($modulo >= 33) {
$grade = "F";
} else {
$grade = "N/A";
}
Read how PHP compare values of different types and read how the switch control structure works.
Here you go
$theusersname = 'theusersname';
$totalmarks = 500;
$mathsobt = 87;
$physicsobt = 82;
$chemistryobt = 75;
$computerobt = 79;
$englishobt = 91;
$totalobt = $mathsobt + $physicsobt + $chemistryobt + $computerobt + $englishobt;
$modulo = ($totalobt / $totalmarks) * 100;
switch ($modulo) {
case $modulo >= 33 && $modulo < 39.5:
$grade = "F";
break;
case $modulo >= 39.5 && $modulo < 49.5:
$grade = "D";
break;
case $modulo >= 49.5 && $modulo < 59.5:
$grade = "C";
break;
case $modulo >= 59.5 && $modulo < 69.5:
$grade = "B";
break;
case $modulo >= 69.5 && $modulo < 79.5:
$grade = "A";
break;
case ($modulo >= 79.5 && $modulo <= 100 ):
$grade = "A-1";
break;
default:
$grade = "N/A";
break;
}
switch ($grade) {
case 'A-1':
$remarks = "You have got A-1 ";
break;
case 'A':
$remarks = "You have got A ";
break;
case 'B':
$remarks = "You have got B ";
break;
case 'C':
$remarks = "You have got C ";
break;
case 'D':
$remarks = "You have got D ";
break;
case 'F':
$remarks = "You have got F ";
break;
default:
$remarks = "You have got nothing";
break;
}
echo $query = "INSERT INTO `report`
(`name`, `grade`, `total`, `mathsobt`, `physicsobt`,
`chemistryobt`, `computerobt`, `englishobt`, `totalobt`,
`modulo`, `remarks`)
VALUES ('$theusersname', '$grade', '$totalmarks', '$mathsobt',
'$physicsobt', '$chemistryobt', '$computerobt', '$englishobt',
'$totalobt', '$modulo', '$remarks')";
OUTPUT
INSERT INTO `report`
(`name`, `grade`, `total`, `mathsobt`, `physicsobt`,
`chemistryobt`, `computerobt`, `englishobt`, `totalobt`,
`modulo`, `remarks`)
VALUES ('theusersname', 'A-1', '500', '87', '82', '75', '79',
'91', '414', '82.8', 'You have got A-1 ')
if (isset($_POST["submit"])){
$oride='';
$count = "25";
$origin = $_POST["origin"];
$destinataion = $_POST["destination"];
$oride = ($destination = $_POST["destination"] - $origin= $_POST["origin"]);
switch (true) {
case ($count<="0"):
echo "invalid";
break;
case ($count==="15"):
echo $count;
break;
case ($count==="16"):
$total = $count + "1";
echo $total;
break;
default:
echo "hello";
} }
The code will compute 1st then execute switch depending on what is the result of the computation. I tried if else but it will be too long because the case will go up to 130.
You must use the var $count in switch statement and the constant in case this way
switch ($count) {
case "0" :
echo "invalid";
break;
case "15":
echo $count;
break;
case "16":
$total = $count + "1";
echo $total;
break;
default:
echo "hello";
break;
}
You have to provide an expression to the switch statement, while the case statements are just "versions" of the result of that expression. The only thing you can NOT do directly is the "<= 0" expression, but you can work around it:
if (isset($_POST["submit"])){
$oride='';
$count = "25";
$origin = $_POST["origin"];
$destinataion = $_POST["destination"];
$oride = ($destination = $_POST["destination"] - $origin= $_POST["origin"]);
// --- normalize $count:
$count = $count <= 0 ? 0 : $count;
// use $count as expression:
switch ($count) {
case 0:
echo "invalid";
break;
case "15":
echo $count;
break;
case "16":
$total = $count + "1";
echo $total;
break;
default:
echo "hello";
} }
This code is supposed to output something like:
You are, at this moment, living in the 11th second of the 2nd minute of the 3rd hour of the 9th day of the 5th month of the 2017th year since the begining of the International calender.
Instead it outputs this: https://prnt.sc/fli92p
Have no idea what the problem is.
date_default_timezone_set(//location...);
say_time();
function say_time()
{
$o = ' of the';
class time_value
{
public $t, $name, $display;
protected $n, $suf;
function __construct()
{
$this->display = " $this->n"."$this->suf"." $this->name";
$this->n = date($this->t,time());
switch ($this->n)
{
case 1:
$suf = 'st';
break;
case 2:
$suf = 'nd';
break;
case 3:
$suf = 'rd';
break;
default:
$suf = 'nth';
break;
}
}
}
$sec = new time_value;
$sec->t = 's';
$sec->name = 'seconds';
$min = new time_value;
$min->t = 'i';
$min->name = 'minutes';
$hr = new time_value;
$hr->t = 'G';
$hr->name = 'hours';
$day = new time_value;
$day->t = 'j';
$day->name = 'days';
$mon = new time_value;
$mon->t = 'n';
$mon->name = 'months';
$yr = new time_value;
$yr->t = 'Y';
$yr->name = 'years';
echo "You are, at this moment, living in the "
.$sec->display .$o
.$min->display .$o
.$hr ->display .$o
.$day->display .$o
.$mon->display .$o
.$yr ->display .
" since the begining of the International calender.";
echo $sec->display;
}
The line:
$this->display = " $this->n"."$this->suf"." $this->name";
is the first line of the class' constructor. It stores in the $display property of the object a string that contains only spaces because the values it contains are not set yet.
Read about double-quotes strings and variables parsing inside double-quotes strings.
In order to work, the class time_value should be like this:
class time_value
{
private $t, $name, $display;
public function __construct($t, $name)
{
$this->t = $t;
$this->name = $name;
$n = date($this->t, time());
switch ($n)
{
case 1:
$suf = 'st';
break;
case 2:
$suf = 'nd';
break;
case 3:
$suf = 'rd';
break;
default:
$suf = 'th';
break;
}
$this->display = " {$n}{$suf} {$this->name}";
}
public function display() { return $this->display; }
}
$sec = new time_value('s', 'seconds');
$min = new time_value('i', 'minutes');
// all the other time components here...
echo $sec->display().$o.$min->display(); // ...
The next step toward object-oriented programming is to encapsulate the generation of all time components into the time_value class (or into another class that uses time_value instances, if you like it more) and have the code of function say_time() look like this:
function say_time()
{
$time = new time_value();
echo "You are, at this moment, living in the ".$time->display("of the")." since the begining of the International calender.";
}