I needed a break …

I mentioned here that I hadn’t yet found out how to add a paragraph or line break within PHP. I searched online but found what looked like fairly complicated programming that seemed too complex for the task at hand (PHP Manual, 2012).  Then, while I was watching Alastair’s Week 5 video lecture (UTS Online, 2012), I saw a <p> tag between lines of PHP code. I did mention that I have an eye for detail in my Learning Proposal….! Anyway, I put in the <p> tags and it worked and the html validated . Here’s the code:

echo “<p>Today, in the USA, the date and time is:”;
echo date(” l jS F Y H:i:s, “);
echo “which is GMT “;
echo date (“P, “);
echo “and this month has “;
echo date(“t”) ;
echo ” days. “;
echo “</p>“;
echo “<p>The timezone is “;
echo date (“T, “);
echo “which is “;
echo date (“e.”);
echo “</p>“;
I’d be willing to bet that there are more elegant, streamlined, and tidy solutions. Please let me know–my programming knowledge is pretty thin so far!


PHP: nl2br – Manual. 2012. PHP: nl2br – Manual, viewed 24 March 2012 <http://au.php.net/nl2br>

UTS Blackboard. 2012, Digital Media Technologies, Subject Materials, viewed 25 March 2012, via login at <https://online.uts.edu.au>

Post a comment or leave a trackback: Trackback URL.


  • k1rt1  On April 7, 2012 at 9:45 am

    Hai Julie,

    The code which you wrote here helped me knowing more about php. Thanks for that. I am still taking baby steps in php :).. Can we writing php code in html parent file itself ?

    • digitaldweller  On April 9, 2012 at 1:45 am

      Hi Kirti
      Thanks, glad it helped! That was my first attempt at PHP coding and I can tell you it took me ages. Time permitting, it’s good to try and work these things out, believe me you remember it afterwards! I think it’s the frustration that helps you remember 🙂

      I’m glad you asked me that question because it made me check out and confirm what I’d suspected was the case: Yes, you can write php inside the html file, but in that case the file must be saved as filename.php, not filename.html. In this case it appears inside php delimiters within the body of the html file.

      A really nice, clear explanation can be found here.

      You can also link a php file to an html file by creating the php file, and placing the php ‘include’ command for the linked php file between the body tags in the HTML file. Explanation is here


      PHP Tutorial – Syntax viewed 9 April 2012, <http://www.tizag.com/phpT/syntax.php>.

      PHP Tutorial – Include File viewed 9 April 2012, <http://www.tizag.com/phpT/include.php>.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

%d bloggers like this: