{"id":39459,"date":"2018-07-16T03:01:39","date_gmt":"2018-07-15T17:01:39","guid":{"rendered":"http:\/\/www.rjmprogramming.com.au\/ITblog\/?p=39459"},"modified":"2018-07-17T15:19:01","modified_gmt":"2018-07-17T05:19:01","slug":"php-strengths-primer-tutorial","status":"publish","type":"post","link":"https:\/\/www.rjmprogramming.com.au\/ITblog\/php-strengths-primer-tutorial\/","title":{"rendered":"PHP Strengths Primer Tutorial"},"content":{"rendered":"<div style=\"width: 230px\" class=\"wp-caption alignnone\"><a title='PHP Strengths Primer Tutorial' href=\"http:\/\/www.rjmprogramming.com.au\/PHP\/hello_world.php\"><img decoding=\"async\" style=\"float:left;border: 15px solid pink;\" alt=\"PHP Strengths Primer Tutorial\" src=\"http:\/\/www.rjmprogramming.com.au\/PHP\/hello_world.jpg\" title=\"PHP Strengths Primer Tutorial\"  \/><\/a><p class=\"wp-caption-text\">PHP Strengths Primer Tutorial<\/p><\/div>\n<p>Yesterday&#8217;s <a target=_blank title='Google Chart Area Bar Column Line Superimposition Share Tutorial' href='https:\/\/www.rjmprogramming.com.au\/ITblog\/google-chart-area-bar-column-line-superimposition-share-tutorial\/'>Google Chart Area Bar Column Line Superimposition Share Tutorial<\/a> blog posting involved some <a target=_blank title='PHP' href='http:\/\/php.net\/'>PHP<\/a> code that reminded me it is time, as far as PHP goes, to go back to the beginning and explain, at least for us &#8230;<\/p>\n<ul>\n<li><em>why (PHP, as your serverside language of choice)?<\/em>\n<ol>\n<li>easy to host (web pages) locally (we like <a target=_blank title='MAMP Apache\/PHP\/MySql local web server' href='https:\/\/mamp.info'>MAMP<\/a> on Mac OS X or Windows) and via Apache\/PHP\/MySql hosting (we use a <a target=_blank title='Crazy Domains' href='https:\/\/crazydomains.com.au'>Crazy Domains<\/a> virtual web server hosting arrangement)<\/li>\n<li>its ready interfacing to many databases such as <a target=_blank title='MySql database' href='https:\/\/www.mysql.com\/'>MySql<\/a><\/li>\n<li>its own inbuilt libraries such as <a target=_blank title='GD and Image Functions' href='http:\/\/php.net\/manual\/en\/ref.image.php'>GD<\/a> (for images) and <a target=_blank title='PHP TimeZone list' href='http:\/\/php.net\/manual\/en\/timezones.php'>TimeZone<\/a> and involving <a target=_blank title='ImageMagick software suite' href='https:\/\/www.imagemagick.org\/'>ImageMagick<\/a> and <a target=_blank title='fpdf' href='http:\/\/www.fpdf.org\/'>PDF<\/a> are powerful programming tools<\/li>\n<li>its close partnership with Javascript to piece together solutions<\/li>\n<li>great documentation and help online and in books and magazines<\/li>\n<li>the client side alone is very limited and the serverside aspects to PHP can add great &#8220;data intelligence&#8221; to your web applications<\/li>\n<li>PHP&#8217;s three modes of use &#8220;surfing the net&#8221;, &#8220;<a target=_blank title='Linux or unix curl information from computerhope' href='http:\/\/www.computerhope.com\/unix\/curl.htm'>curl<\/a>&#8220;, &#8220;command line&#8221; (of <a title='PHP Strengths Primer Tutorial' href=\"http:\/\/www.rjmprogramming.com.au\/PHP\/hello_world.php_GETME\">hello_world.php<\/a>) as &#8230;<br \/>\n<table cellpadding=0 cellspacing=0 style='width:100%;'>\n<tr>\n<th style='width:100%;word-wrap:break-word;'>&#8220;surfing the net&#8221;<\/th>\n<\/tr>\n<tr>\n<td style='vertical-align:top;width:100%;word-wrap:break-word;font-size:8px;'>HTTP:\/\/www.rjmprogramming.com.au\/PHP\/hello_world.php?m=hello%20world<\/td>\n<\/tr>\n<tr>\n<td style='vertical-align:top;width:100%;word-wrap:break-word;'><iframe src='\/\/www.rjmprogramming.com.au\/PHP\/hello_world.php?m=hello%20world'><\/iframe><\/td>\n<\/tr>\n<tr>\n<th style='width:100%;word-wrap:break-word;'>&#8220;curl&#8221;<\/th>\n<\/tr>\n<tr>\n<td style='vertical-align:top;width:100%;word-wrap:break-word;font-size:8px;'>curl HTTP:\/\/www.rjmprogramming.com.au\/PHP\/hello_world.php?m=hello%20world<\/td>\n<\/tr>\n<tr>\n<td style='vertical-align:top;width:100%;word-wrap:break-word;'>hello world<\/td>\n<\/tr>\n<tr>\n<th style='width:100%;word-wrap:break-word;'>&#8220;command line&#8221;<\/th>\n<\/tr>\n<tr>\n<td style='vertical-align:top;width:100%;word-wrap:break-word;font-size:8px;'>cd \/Applications\/MAMP\/htdocs # eg. MAMP (same code base of HTTP:\/\/localhost:8888\/hello_world.php?m=hello%20world usage)<br \/>php hello_world.php hello world<\/td>\n<\/tr>\n<tr>\n<td style='vertical-align:top;width:100%;word-wrap:break-word;'>hello world<\/td>\n<\/tr>\n<\/table>\n<\/li>\n<li>to learn PHP well as a server side language, perhaps your first, can help you appreciate others such as Python or Perl or ASP.Net and the server part to frameworks such as <a target=_blank title='Node.js installation download webpage' href='https:\/\/nodejs.org\/en\/download\/'>Node.js<\/a> or <a target=_blank title='MeteorJS Javascript Framework' href='https:\/\/www.meteor.com\/'>MeteorJS<\/a><\/li>\n<\/ol>\n<\/li>\n<li><em>how?<\/em>\n<ol>\n<li>locally (we like <a target=_blank title='MAMP Apache\/PHP\/MySql local web server' href='https:\/\/mamp.info'>MAMP<\/a> on Mac OS X or Windows) and via Apache\/PHP\/MySql hosting (we use a Crazy Domains virtual web server hosting arrangement)<\/li>\n<li>on Mac OS X we use a text editor like <a target=_blank href='http:\/\/www.macupdate.com\/app\/mac\/11009\/textwrangler' title='Mac TextWrangler text editor'>TextWrangler<\/a> or you could use an IDE such as <a target=_blank title='PHPStorm IDE' href='https:\/\/www.jetbrains.com\/phpstorm\/'>PHPStorm<\/a> or <a target=_blank title='NetBeans IDE' href='http:\/\/netbeans.org'>NetBeans<\/a><\/li>\n<li>coding style wise it was yesterday&#8217;s <a target=_blank title='Google Chart Area Bar Column Line Superimposition Share Tutorial' href='https:\/\/www.rjmprogramming.com.au\/ITblog\/google-chart-area-bar-column-line-superimposition-share-tutorial\/'>Google Chart Area Bar Column Line Superimposition Share Tutorial<\/a> blog posting we want to &#8220;channel&#8221; to propose a three tier PHP coding style that may help you interpret PHP code you see &#8230;<br \/>\n<table cellpadding=0 cellspacing=0 style='width:360px;'>\n<tr>\n<th style='width:120px;'>PHP Only Code Blocks<\/th>\n<th style='width:120px;'>PHP Makes Way or Intervenes<\/th>\n<th style='width:120px;'>PHP the Echoing Partner to Javascript or CSS or HTML<\/th>\n<\/tr>\n<tr>\n<td style='vertical-align:top;width:120px;'><code style='font-size:8px;width:120px;'>&lt;?php<br \/>\n    echo \"    var documentURL='' , locationhref='', returl='', dccnt=0, topmou='', etodi='emailee', etodicc='EmailCC', etodibcc='EmailBCC', etodisubject='EmailSubject';<br \/>\n    if (document.URL.indexOf('file:') != 0) {<br \/>\n    documentURL=document.URL;<br \/>\n    documentURL=documentURL.split('#')[0];<br \/>\n    }<br \/>\n    \";<br \/>\n&nbsp;<br \/>\n&nbsp;<br \/>\n      $appval=$_SERVER['QUERY_STRING'];<br \/>\n      if ($appval != '' && strpos($appval, '?') === false) {<br \/>\n        $appval='?' . $_SERVER['QUERY_STRING'];<br \/>\n      }<br \/>\n      if (isset($_POST['data'])) {<br \/>\n        $appval=\"\";<br \/>\n        $appvald=\"?\";<br \/>\n        if (strlen($_SERVER['QUERY_STRING']) &gt; 1) $appvald=\"&\";<br \/>\n        foreach ($_POST as $name =&gt; $val) {<br \/>\n          if ($name != \"snow\" . \"white\") {<br \/>\n            $appval.=$appvald . htmlspecialchars($name) . \"=\" . str_replace(\"+\",\"%20\",urlencode(htmlspecialchars($val)));<br \/>\n            $appvald=\"&\";<br \/>\n          }<br \/>\n        }<br \/>\n        echo \"\\n documentURL=document.URL.split('#')[0] + \\\"\" . str_replace(\"\\n\", \" \", $appval) . \"\\\";   \\n\";<br \/>\n      }<br \/>\n?&gt;<\/code><\/td>\n<td style='vertical-align:top;width:120px;'><code style='font-size:8px;width:120px;'>    function goother(aothis) {<br \/>\n      var fromone='\/BarChart';<br \/>\n      var fromtwo='bar_chart.php';<br \/>\n      var returl=documentURL.split('#')[0];<br \/>\n      if (!aothis) {<br \/>\n       if (dccnt != 0) topmou='BarChart\/bar_chart.php';<br \/>\n&lt;?php<br \/>\n       if (isset($_GET['overlay'])) {<br \/>\n       if (substr(strtolower(str_replace('+',' ',urldecode($_GET['overlay'])) . \" \"),0,1) == ',') {<br \/>\n       echo \"\\n returl=returl.split('data=')[0] + 'data=\" . urlencode(str_replace('+',' ',urldecode($_GET['overlay']))) . \"'; \\n\";<br \/>\n       } else if (strpos(substr(strtolower(str_replace('+',' ',urldecode($_GET['overlay'])) . \" \"),0), \",\") !== false) {<br \/>\n       echo \"\\n returl=returl.split('data=')[0] + 'data=\" . urlencode(',' . str_replace(explode(\",\",str_replace('+',' ',urldecode($_GET['overlay'])))[0] . ',','',str_replace('+',' ',urldecode($_GET['overlay'])))) . \"'; \\n\";<br \/>\n       }<br \/>\n       } else if (isset($_POST['overlay'])) {<br \/>\n       if (substr(strtolower(str_replace('+',' ',urldecode($_POST['overlay'])) . \" \"),0,1) == ',') {<br \/>\n       echo \"\\n returl=returl.split('data=')[0] + 'data=\" . urlencode(str_replace('+',' ',urldecode($_POST['overlay']))) . \"'; \\n\";<br \/>\n       } else if (strpos(substr(strtolower(str_replace('+',' ',urldecode($_POST['overlay'])) . \" \"),0), \",\") !== false) {<br \/>\n       echo \"\\n returl=returl.split('data=')[0] + 'data=\" . urlencode(',' . str_replace(explode(\",\",str_replace('+',' ',urldecode($_POST['overlay'])))[0] . ',','',str_replace('+',' ',urldecode($_POST['overlay'])))) . \"'; \\n\";<br \/>\n       }<br \/>\n       }<br \/>\n?&gt;<br \/>\n      } else if (aothis.innerHTML.toLowerCase().indexOf('area') != -1) {<br \/>\n       if (dccnt != 0) topmou='AreaChart\/area_chart.php';<br \/>\n       returl=returl.replace(fromone,'\/AreaChart').replace(fromtwo,'area_chart.php').replace('index.php','area_chart.php');<br \/>\n      } else if (aothis.innerHTML.toLowerCase().indexOf('bar') != -1) {<br \/>\n       if (dccnt != 0) topmou='BarChart\/bar_chart.php';<br \/>\n       returl=returl.replace(fromone,'\/BarChart').replace(fromtwo,'bar_chart.php').replace('index.php','bar_chart.php');<br \/>\n      } else if (aothis.innerHTML.toLowerCase().indexOf('column') != -1) {<br \/>\n       if (dccnt != 0) topmou='ColumnChart\/column_chart.php';<br \/>\n       returl=returl.replace(fromone,'\/ColumnChart').replace(fromtwo,'column_chart.php').replace('index.php','column_chart.php');<br \/>\n      } else if (aothis.innerHTML.toLowerCase().indexOf('line') != -1) {<br \/>\n       if (dccnt != 0) topmou='LineChart\/line_chart.php';<br \/>\n       returl=returl.replace(fromone,'\/LineChart').replace(fromtwo,'line_chart.php').replace('index.php','line_chart.php');<br \/>\n      }<br \/>\n      postgoother(returl);<br \/>\n      return returl;<br \/>\n    }<\/code><\/td>\n<td style='vertical-align:top;width:120px;'><code style='font-size:8px;width:120px;'>         document.getElementById('thedivoverlay').innerHTML='&lt;iframe id=thedivoverlayi name=thedivoverlayi style=\"opacity:&lt;?php echo $op; ?&gt;;z-index:9;position:absolute;top:&lt;?php echo $tpy; ?&gt;px;left:&lt;?php echo $lfx; ?&gt;px;width:' + eval(rect.right - rect.left) + 'px;height:' + eval(rect.bottom - rect.top) + 'px;\" src=\"' + 'about:blank' + '\"&gt;&lt;\/iframe&gt;';<br \/>\n<\/code><\/td>\n<\/tr>\n<\/table>\n<\/li>\n<\/ol>\n<\/li>\n<li>set yourself challenges starting with a &#8220;Hello World&#8221; such as creating a PHP webpage in the three ways above that shows &#8220;Hello World&#8221; at a url such as HTTP:\/\/localhost:8888\/hello_world.php<\/li>\n<\/li>\n<li><em>where?<\/em>\n<ol>\n<li>locally (we like MAMP on Mac OS X or Windows) and via Apache\/PHP\/MySql hosting (we use a Crazy Domains virtual web server hosting arrangement)<\/li>\n<li>best online webpages start at <a target=_blank title='PHP' href='http:\/\/php.net\/'>&#8220;the home of PHP&#8221;<\/a><\/li>\n<li>we like the books\n<p style='display:inline;'><i>Professional PHP Programming<\/i> by Jesus Castagnetto (ISBN: 1-8610029-6-3), <\/p>\n<p style='display:inline;'><i>PHP and MySQL Web Development<\/i> by Luke Welling and Laura Thomson (ISBN: 0-6723291-6-6), <\/p>\n<p style='display:inline;'><i>The PHP Anthology (Volume II: Applications)<\/i> by Harry Fuecks (ISBN: 0-9579218-4-5)<\/p>\n<\/li>\n<\/ol>\n<\/li>\n<li><em>when?<\/em><br \/>\n &#8230; try PHP today!\n<\/li>\n<\/ul>\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='#d39459' onclick='var dv=document.getElementById(\"d39459\"); dv.innerHTML = \"&lt;iframe width=670 height=600 src=\" + \"https:\/\/www.rjmprogramming.com.au\/ITblog\/tag\/php\" + \"&gt;&lt;\/iframe&gt;\"; dv.style.display = \"block\";'>this<\/a> too.<\/p>\n<div id='d39459' style='display: none; border-left: 2px solid green; border-top: 2px solid green;'><\/div>\n","protected":false},"excerpt":{"rendered":"<p>Yesterday&#8217;s Google Chart Area Bar Column Line Superimposition Share Tutorial blog posting involved some PHP code that reminded me it is time, as far as PHP goes, to go back to the beginning and explain, at least for us &#8230; &hellip; <a href=\"https:\/\/www.rjmprogramming.com.au\/ITblog\/php-strengths-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,37],"tags":[85,213,299,1550,572,590,1658,827,932,997,1122,1166,1693,1319,1411],"class_list":["post-39459","post","type-post","status-publish","format-standard","hentry","category-elearning","category-tutorials","tag-apache","tag-clientserver","tag-database-2","tag-gd","tag-hosting","tag-image","tag-imagemagick","tag-mysql","tag-php","tag-programming","tag-server","tag-software-2","tag-timezone","tag-tutorial","tag-web-server"],"_links":{"self":[{"href":"https:\/\/www.rjmprogramming.com.au\/ITblog\/wp-json\/wp\/v2\/posts\/39459"}],"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=39459"}],"version-history":[{"count":50,"href":"https:\/\/www.rjmprogramming.com.au\/ITblog\/wp-json\/wp\/v2\/posts\/39459\/revisions"}],"predecessor-version":[{"id":39546,"href":"https:\/\/www.rjmprogramming.com.au\/ITblog\/wp-json\/wp\/v2\/posts\/39459\/revisions\/39546"}],"wp:attachment":[{"href":"https:\/\/www.rjmprogramming.com.au\/ITblog\/wp-json\/wp\/v2\/media?parent=39459"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.rjmprogramming.com.au\/ITblog\/wp-json\/wp\/v2\/categories?post=39459"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.rjmprogramming.com.au\/ITblog\/wp-json\/wp\/v2\/tags?post=39459"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}