{"id":8645,"date":"2014-07-28T05:15:18","date_gmt":"2014-07-27T19:15:18","guid":{"rendered":"http:\/\/www.rjmprogramming.com.au\/wordpress\/?p=8645"},"modified":"2014-07-28T05:15:18","modified_gmt":"2014-07-27T19:15:18","slug":"static-html-based-php-primer-tutorial","status":"publish","type":"post","link":"https:\/\/www.rjmprogramming.com.au\/ITblog\/static-html-based-php-primer-tutorial\/","title":{"rendered":"Static HTML Based PHP Primer Tutorial"},"content":{"rendered":"<div style=\"width: 230px\" class=\"wp-caption alignnone\"><a target=_blank href=\"http:\/\/www.rjmprogramming.com.au\/PHP\/SimpleStaticHTML\/simple_supervisor.html\"><img decoding=\"async\" style=\"float:left; border: 15px solid pink;\" alt=\"Static HTML Based PHP Primer Tutorial\" src=\"http:\/\/www.rjmprogramming.com.au\/PHP\/SimpleStaticHTML\/simple_supervisor.jpg\" title=\"Static HTML Based PHP Primer Tutorial\" \/><\/a><p class=\"wp-caption-text\">Static HTML Based PHP Primer Tutorial<\/p><\/div>\n<p>Today&#8217;s tutorial is like a step back &#8230; a woah! &#8230; to people familiar with PHP.   Even so, those PHP experts may like to rethink on things back to the day they first took it up &#8230; did you skirt past some of the PHP possibilities, possibly for good reasons like consistency and speed of coding, yet you would like to reassess other ways?   What I am getting at, is that PHP, being the <a target=_blank href='http:\/\/en.wikipedia.org\/wiki\/List_of_programming_languages_by_type#Interpreted_languages' title='Interpreted language list from Wikipedia ... thanks'><i>interpretive<\/i><\/a> web server-side (or desktop) language that it is, is quite flexible with styles of coding that can be used.   We are not talking about code modules or <a target=_blank href='http:\/\/au2.php.net\/manual\/en\/function.include.php' title='PHP include information'><i>include<\/i><\/a> or <a target=_blank href='http:\/\/au2.php.net\/manual\/en\/function.require.php' title='PHP require information'<i>require<\/i><\/a> here &#8230; rather we are just paring it back to different ways you can think of PHP and its association with simple static HTML, which, today, we got from <a target=_blank href='http:\/\/www.w3schools.com\/html\/tryit.asp?filename=tryhtml_intro' title='Most simple static HTML example to try, from w3schools ... thanks'>w3schools<\/a> &#8230; thanks.<\/p>\n<p>So today, would like you to put yourself in the position of being given some simple static HTML, that works.   Yay!   This is the most important thing, but here is the other thing &#8230; PHP is great at taking that simple working static HTML and turning it from a sow&#8217;s ear into a silk purse &#8230; personally, think the pig is kind of cute to begin with &#8230; but moi digresses.<\/p>\n<p>You can make the static HTML stand out by having many broken up &lt;?php &#8230; ?&gt; blocks (or none, for the odd scenario where your PHP is pure HTML).<\/p>\n<p>You can make the static HTML be immersed into the PHP by having only one or just a few &lt;?php &#8230; ?&gt; block(s).<\/p>\n<p>You can make the static HTML be like a data source used by the PHP by having the static HTML be read, via <a target=_blank href='http:\/\/au1.php.net\/manual\/en\/function.file-get-contents.php' title='PHP file_get_contents information'><i>file_get_contents<\/i><\/a>, for example,  and work the changes (<i>business logic<\/i>) within one, or just a few &lt;?php &#8230; ?&gt; block(s).<\/p>\n<p>It is hard to say what you are going to think is progressive coding or not, and really think you should not sneer at any particular coding style unless you have a good reason never to use a particular style as above, perhaps for reasons of readability or modularization.  Anyway, today we show two bits of original simple HTML (they have a red border, the original w3schools code being the top left one) and PHP coding style progressions off that in various styles.   Use the code examinations below in conjunction with This Frame-&gt;View Frame Source and This Frame-&gt;View Frame Info to get the whole picture of various approaches to achieve (almost) the same ends.<\/p>\n<p>The HTML and PHP supervisory programming source code can be seen below:<\/p>\n<ul>\n<li>\n<a target=_blank  href=\"http:\/\/www.rjmprogramming.com.au\/PHP\/SimpleStaticHTML\/simple_supervisor.html-GETME\" title='Supervisory HTML'>simple_supervisor.html<\/a>\n<\/li>\n<\/ul>\n<p>The HTML and PHP supervised programming source code can be seen below:<\/p>\n<ul>\n<li>\n<a target=_blank  href=\"http:\/\/www.rjmprogramming.com.au\/PHP\/SimpleStaticHTML\/simple.html-GETME\" title='Original simple static HTML'>simple.html<\/a>  &#8230; let&#8217;s start with some working static HTML from <a target=_blank href='http:\/\/www.w3schools.com\/html\/tryit.asp?filename=tryhtml_intro' title='Most simple static HTML example to try, from w3schools ... thanks'>w3schools<\/a> &#8230; thanks\n<\/li>\n<li>\n<a target=_blank  href=\"http:\/\/www.rjmprogramming.com.au\/PHP\/SimpleStaticHTML\/simple.php-GETME\" title='Simplest PHP version'>simple.php<\/a> &#8230; PHP can be the HTML itself\n<\/li>\n<li>\n<a target=_blank  href=\"http:\/\/www.rjmprogramming.com.au\/PHP\/SimpleStaticHTML\/simple_0.php-GETME\" title='Next PHP'>simple_0.php<\/a> &#8230; PHP can be no more than readiness for PHP code up the top with the rest being the static HTML\n<\/li>\n<li>\n<a target=_blank  href=\"http:\/\/www.rjmprogramming.com.au\/PHP\/SimpleStaticHTML\/simple_00.php-GETME\" title='Next PHP'>simple_00.php<\/a> &#8230; PHP can read its HTML from a static HTML file on the server\n<\/li>\n<li>\n<a target=_blank  href=\"http:\/\/www.rjmprogramming.com.au\/PHP\/SimpleStaticHTML\/simple_1.php-GETME\" title='Next PHP'>simple_1.php<\/a> &#8230; PHP can <i>&#8220;subsume&#8221;<\/i> the HTML code into its <i>&#8220;bowels&#8221;<\/i> &#8230; easy, boy!\n<\/li>\n<li>\n<a target=_blank  href=\"http:\/\/www.rjmprogramming.com.au\/PHP\/SimpleStaticHTML\/simple_2.php-GETME\" title='Next PHP'>simple_2.php<\/a> &#8230; PHP can leave HTML as it is when it is clearly static by nature, and create a new <i>subsuming<\/i> total-code-line PHP block with logic in it for bits that are parameterizable\n<\/li>\n<li>\n<a target=_blank  href=\"http:\/\/www.rjmprogramming.com.au\/PHP\/SimpleStaticHTML\/simple_3.php-GETME\" title='Next PHP'>simple_3.php<\/a> &#8230; PHP can leave HTML as it is when it is clearly static by nature, and create a new less <i>subsuming<\/i> PHP block with logic in it for bits that are parameterizable, leaving static HTML remaining, as is, where possible\n<\/li>\n<li>\n<a target=_blank  href=\"http:\/\/www.rjmprogramming.com.au\/PHP\/SimpleStaticHTML\/simple_get.html-GETME\" title='Original HTML with Javascript get parameter checking'>simple_get.html<\/a> &#8230; let&#8217;s start with some new HTML that uses Javascript to process GET parameters on the URL (but not POST parameters from a form)\n<\/li>\n<li>\n<a target=_blank  href=\"http:\/\/www.rjmprogramming.com.au\/PHP\/SimpleStaticHTML\/simple_get.php-GETME\" title='Original HTML with Javascript get parameter checking'>simple_get.php<\/a> &#8230; PHP can read its HTML from a static HTML file on the server, and then apply business logic to that HTML to transform it into something more useful, dynamic and parameterizable\n<\/li>\n<li>\n<a target=_blank  href=\"http:\/\/www.rjmprogramming.com.au\/PHP\/SimpleStaticHTML\/simple_get_0.php-GETME\" title='Original HTML with Javascript get parameter checking'>simple_get_0.php<\/a> &#8230; PHP can be basically the static HTML with the parameter bits transformed into midline bits of PHP code to handle that particular parameter&#8217;s logic\n<\/li>\n<li>\n<a target=_blank  href=\"http:\/\/www.rjmprogramming.com.au\/PHP\/SimpleStaticHTML\/simple_get_1.php-GETME\" title='Original HTML with Javascript get parameter checking'>simple_get_1.php<\/a> &#8230; PHP can use its strength with HTML forms to be the complete solution to a form-based web page asking for user input and responding to that user&#8217;s interactions, in POST (PHP processes it) or GET (where the PHP leaves it to Javascript) mode, but based, template-wise on the static HTML of interest\n<\/li>\n<\/ul>\n<p>The progression of code can be seen with the code difference analyses below:<\/p>\n<ul>\n<li>\n<a target=_blank  href=\"http:\/\/www.rjmprogramming.com.au\/PHP\/Geographicals\/diff.php?minus=-y&#038;one=http:\/\/www.rjmprogramming.com.au\/PHP\/SimpleStaticHTML\/simple.html-GETME\" title='Original simple static HTML'>simple.html<\/a>\n<\/li>\n<li>\n<a target=_blank  href=\"http:\/\/www.rjmprogramming.com.au\/PHP\/Geographicals\/diff.php?minus=-y&#038;one=http:\/\/www.rjmprogramming.com.au\/PHP\/SimpleStaticHTML\/simple.php-GETME\" title='Simplest PHP version'>simple.php<\/a>\n<\/li>\n<li>\n<a target=_blank  href=\"http:\/\/www.rjmprogramming.com.au\/PHP\/Geographicals\/diff.php?minus=-y&#038;one=http:\/\/www.rjmprogramming.com.au\/PHP\/SimpleStaticHTML\/simple_0.php-GETME\" title='Next PHP'>simple_0.php<\/a>\n<\/li>\n<li>\n<a target=_blank  href=\"http:\/\/www.rjmprogramming.com.au\/PHP\/Geographicals\/diff.php?minus=-y&#038;one=http:\/\/www.rjmprogramming.com.au\/PHP\/SimpleStaticHTML\/simple_00.php-GETME\" title='Next PHP'>simple_00.php<\/a>\n<\/li>\n<li>\n<a target=_blank  href=\"http:\/\/www.rjmprogramming.com.au\/PHP\/Geographicals\/diff.php?minus=-y&#038;one=http:\/\/www.rjmprogramming.com.au\/PHP\/SimpleStaticHTML\/simple_1.php-GETME\" title='Next PHP'>simple_1.php<\/a>\n<\/li>\n<li>\n<a target=_blank  href=\"http:\/\/www.rjmprogramming.com.au\/PHP\/Geographicals\/diff.php?minus=-y&#038;one=http:\/\/www.rjmprogramming.com.au\/PHP\/SimpleStaticHTML\/simple_2.php-GETME\" title='Next PHP'>simple_2.php<\/a>\n<\/li>\n<li>\n<a target=_blank  href=\"http:\/\/www.rjmprogramming.com.au\/PHP\/Geographicals\/diff.php?minus=-y&#038;one=http:\/\/www.rjmprogramming.com.au\/PHP\/SimpleStaticHTML\/simple_3.php-GETME\" title='Next PHP'>simple_3.php<\/a>\n<\/li>\n<li>\n<a target=_blank  href=\"http:\/\/www.rjmprogramming.com.au\/PHP\/Geographicals\/diff.php?minus=-y&#038;one=http:\/\/www.rjmprogramming.com.au\/PHP\/SimpleStaticHTML\/simple_get.html-GETME\" title='Original HTML with Javascript get parameter checking'>simple_get.html<\/a>\n<\/li>\n<li>\n<a target=_blank  href=\"http:\/\/www.rjmprogramming.com.au\/PHP\/Geographicals\/diff.php?minus=-y&#038;one=http:\/\/www.rjmprogramming.com.au\/PHP\/SimpleStaticHTML\/simple_get.php-GETME\" title='Original HTML with Javascript get parameter checking'>simple_get.php<\/a>\n<\/li>\n<li>\n<a target=_blank  href=\"http:\/\/www.rjmprogramming.com.au\/PHP\/Geographicals\/diff.php?minus=-y&#038;one=http:\/\/www.rjmprogramming.com.au\/PHP\/SimpleStaticHTML\/simple_get_0.php-GETME\" title='Original HTML with Javascript get parameter checking'>simple_get_0.php<\/a>\n<\/li>\n<li>\n<a target=_blank  href=\"http:\/\/www.rjmprogramming.com.au\/PHP\/Geographicals\/diff.php?minus=-y&#038;one=http:\/\/www.rjmprogramming.com.au\/PHP\/SimpleStaticHTML\/simple_get_1.php-GETME\" title='Original HTML with Javascript get parameter checking'>simple_get_1.php<\/a>\n<\/li>\n<\/ul>\n<p>Hope you get something out of the <a target=_blank href=\"http:\/\/www.rjmprogramming.com.au\/PHP\/SimpleStaticHTML\/simple_supervisor.html\" title=\"Click picture\">tutorial<\/a> above.<\/p>\n<p>If this was interesting you may be interested in <a title='Click here to see topics in which you might be interested' href='#d8645' onclick='var dv=document.getElementById(\"d8645\"); dv.innerHTML = \"&lt;iframe width=670 height=600 src=\" + \"http:\/\/www.rjmprogramming.com.au\/wordpress\/?tag=PHP\" + \"&gt;&lt;\/iframe&gt;\"; dv.style.display = \"block\";'>this<\/a> too.<\/p>\n<div id='d8645' style='display: none; border-left: 2px solid green; border-top: 2px solid green;'><\/div>\n","protected":false},"excerpt":{"rendered":"<p>Today&#8217;s tutorial is like a step back &#8230; a woah! &#8230; to people familiar with PHP. Even so, those PHP experts may like to rethink on things back to the day they first took it up &#8230; did you skirt &hellip; <a href=\"https:\/\/www.rjmprogramming.com.au\/ITblog\/static-html-based-php-primer-tutorial\/\">Continue reading <span class=\"meta-nav\">&rarr;<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[12,33,37],"tags":[213,576,652,932,997,1166,1319],"class_list":["post-8645","post","type-post","status-publish","format-standard","hentry","category-elearning","category-software","category-tutorials","tag-clientserver","tag-html","tag-javascript","tag-php","tag-programming","tag-software-2","tag-tutorial"],"_links":{"self":[{"href":"https:\/\/www.rjmprogramming.com.au\/ITblog\/wp-json\/wp\/v2\/posts\/8645"}],"collection":[{"href":"https:\/\/www.rjmprogramming.com.au\/ITblog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.rjmprogramming.com.au\/ITblog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.rjmprogramming.com.au\/ITblog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.rjmprogramming.com.au\/ITblog\/wp-json\/wp\/v2\/comments?post=8645"}],"version-history":[{"count":0,"href":"https:\/\/www.rjmprogramming.com.au\/ITblog\/wp-json\/wp\/v2\/posts\/8645\/revisions"}],"wp:attachment":[{"href":"https:\/\/www.rjmprogramming.com.au\/ITblog\/wp-json\/wp\/v2\/media?parent=8645"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.rjmprogramming.com.au\/ITblog\/wp-json\/wp\/v2\/categories?post=8645"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.rjmprogramming.com.au\/ITblog\/wp-json\/wp\/v2\/tags?post=8645"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}