php hello world

on the code below is the structure of how you can incoporate php to html, to write present time with your php languguage and using comment are all documented on the code below, you are free to copy and test or use the code on your project
<!DOCTYPE html PUBLIC “-//W3C//DTD XHTML 1.0 Strict //EN”
“http://www.w3.org/TR/xhtml1/DTD/xhtml1-Strict.dtd”>
<html xmlns=”http://www.w3.org/1999/xhtml” xml:lang=”en” lang= “en”>
<head>
<title> Hello</title>
<link rel=”stylesheet” type=”text/css” href=”common.css” />
</head>
<body>
<h1>
<?php
// get the current time is readable format
$currentTime = date( “g:i:sa. M:j:Y” );
//Display greeting and time to the visitor
 echo “Hello, world! The current time is $currentTime”
 ?>
 <?php
 $widgetsleft = 10;
 while ($widgetsleft > 0) {
echo “Selling a widget…”;
$widgetsleft–;
echo “done. There are $widgetsleft widget lefts. <br />”;
 }
 echo “We’re right out of widget!”;
 ?>
 <?php
  $widgets = 23;
 if ($widgets == 23) {
echo “we have exactly 23 widgets in stock!”;
 }
 ?>
 <?php
 $widgets = 23;
 if ($widgets >= 10 && $widgets<= 20) {
echo “we have between 10 and 20 widgets in stock.”;
 }
 ?>
 <?php
 if ($userAction == “open”) {
 //open the file
 } elseif ( $userAction == “save” ) {
// save the file
 } elseif ( $userAction == “close” ) {
// Close the file
 } elseif ( $userAction== “logout”) {
// Log the user out
 } else {
print ” please choose an option”;
 }
 ?>
 <?php
 switch ($userAction) {
 case “open”:
 // Open the file
 break;
 case “save”:
 // Save the file
 beak;
 case “Close”:
 // Close the file
 break;
 case “logout”:
 // Log the user  out
 break;
 default:
 print “Please choose and option”;
 }
 ?>
 <?php
 $widgets = 23;
 $plenty = “We have plenty of widgets in stock”;
 $few = ” Less than 10 widgets left. Time to order some more!”;
 echo ( $widgets >= 10) ? $plenty : $few;
 ?>
 ?>
</body>
</html>
please if you find any bug on the code above dont forget to shareit  on  the comment section below. it will help us to improve. thank you.
See also  Nigeria Covid-19 cases hits 39,977, 856 deaths

Be the first to comment

Leave a Reply

Your email address will not be published.


*