ENHANCING THE SCRIPT FURTHER

ENHANCING THE SCRIPT FURTHER

Hello world! is an illustration on how you can write simple PHP code, and test it either if your code is properly written. But these code does not provide any more useful information. the reason we said that the code did not provide useful information is that you can achieved Hello world! Task with HTML, as you achieved with PHP written code.

On these post when going to teach you have you can enhance the script to show current time on your browser, anytime you test your code. By learning these procedure you have excel from static web page creation to dynamic web page that change whenever you view the code. Below are the modified code:

<!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=”omokoshaban.com” />
</head>
<body>
<h1>
<?php
$currentTime = date( “g:i:s a” );
echo “Hello, world! The current time is $currentTime”;
?>
</h1>
</body>
</html>

After you’ve successfully written the code above, you can save it with any name you want and then view the code on your browser, it should display a page shown below,

hello

but sometimes you might encounter a warning message, informing you that its not safe to depend on a system time zone setting.

You should configure your PHP’s time zone as such try configure your PHP time zone now if you examine the code very well, no change take with a code that display Hello world except that the following code is added

See also  #Bbnaija: Nollywood Actor, Yul Edochie campaign for whitemoney, urge followers to vote him to victory

< ?php $currentTime = date( “g:i:s a” ); echo “Hello, world! The current time is $currentTime”; ? >

The mechanism behind these command is that the first line of code retrieve the current time format and then format it to a string text that can be read, after that the text string is stored as a variable called $currentTime.

Be the first to comment

Leave a Reply

Your email address will not be published.


*