Yesterday’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 …
- why (PHP, as your serverside language of choice)?
- easy to host (web pages) 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)
- its ready interfacing to many databases such as MySql
- its own inbuilt libraries such as GD (for images) and TimeZone and involving ImageMagick and PDF are powerful programming tools
- its close partnership with Javascript to piece together solutions
- great documentation and help online and in books and magazines
- the client side alone is very limited and the serverside aspects to PHP can add great “data intelligence” to your web applications
- PHP’s three modes of use “surfing the net”, “curl“, “command line” (of hello_world.php) as …
“surfing the net” HTTP://www.rjmprogramming.com.au/PHP/hello_world.php?m=hello%20world “curl” curl HTTP://www.rjmprogramming.com.au/PHP/hello_world.php?m=hello%20world hello world “command line” cd /Applications/MAMP/htdocs # eg. MAMP (same code base of HTTP://localhost:8888/hello_world.php?m=hello%20world usage)
php hello_world.php hello worldhello world - 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 Node.js or MeteorJS
- how?
- 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)
- on Mac OS X we use a text editor like TextWrangler or you could use an IDE such as PHPStorm or NetBeans
- coding style wise it was yesterday’s Google Chart Area Bar Column Line Superimposition Share Tutorial blog posting we want to “channel” to propose a three tier PHP coding style that may help you interpret PHP code you see …
PHP Only Code Blocks PHP Makes Way or Intervenes PHP the Echoing Partner to Javascript or CSS or HTML <?php
echo " var documentURL='' , locationhref='', returl='', dccnt=0, topmou='', etodi='emailee', etodicc='EmailCC', etodibcc='EmailBCC', etodisubject='EmailSubject';
if (document.URL.indexOf('file:') != 0) {
documentURL=document.URL;
documentURL=documentURL.split('#')[0];
}
";
$appval=$_SERVER['QUERY_STRING'];
if ($appval != '' && strpos($appval, '?') === false) {
$appval='?' . $_SERVER['QUERY_STRING'];
}
if (isset($_POST['data'])) {
$appval="";
$appvald="?";
if (strlen($_SERVER['QUERY_STRING']) > 1) $appvald="&";
foreach ($_POST as $name => $val) {
if ($name != "snow" . "white") {
$appval.=$appvald . htmlspecialchars($name) . "=" . str_replace("+","%20",urlencode(htmlspecialchars($val)));
$appvald="&";
}
}
echo "\n documentURL=document.URL.split('#')[0] + \"" . str_replace("\n", " ", $appval) . "\"; \n";
}
?>function goother(aothis) {
var fromone='/BarChart';
var fromtwo='bar_chart.php';
var returl=documentURL.split('#')[0];
if (!aothis) {
if (dccnt != 0) topmou='BarChart/bar_chart.php';
<?php
if (isset($_GET['overlay'])) {
if (substr(strtolower(str_replace('+',' ',urldecode($_GET['overlay'])) . " "),0,1) == ',') {
echo "\n returl=returl.split('data=')[0] + 'data=" . urlencode(str_replace('+',' ',urldecode($_GET['overlay']))) . "'; \n";
} else if (strpos(substr(strtolower(str_replace('+',' ',urldecode($_GET['overlay'])) . " "),0), ",") !== false) {
echo "\n returl=returl.split('data=')[0] + 'data=" . urlencode(',' . str_replace(explode(",",str_replace('+',' ',urldecode($_GET['overlay'])))[0] . ',','',str_replace('+',' ',urldecode($_GET['overlay'])))) . "'; \n";
}
} else if (isset($_POST['overlay'])) {
if (substr(strtolower(str_replace('+',' ',urldecode($_POST['overlay'])) . " "),0,1) == ',') {
echo "\n returl=returl.split('data=')[0] + 'data=" . urlencode(str_replace('+',' ',urldecode($_POST['overlay']))) . "'; \n";
} else if (strpos(substr(strtolower(str_replace('+',' ',urldecode($_POST['overlay'])) . " "),0), ",") !== false) {
echo "\n returl=returl.split('data=')[0] + 'data=" . urlencode(',' . str_replace(explode(",",str_replace('+',' ',urldecode($_POST['overlay'])))[0] . ',','',str_replace('+',' ',urldecode($_POST['overlay'])))) . "'; \n";
}
}
?>
} else if (aothis.innerHTML.toLowerCase().indexOf('area') != -1) {
if (dccnt != 0) topmou='AreaChart/area_chart.php';
returl=returl.replace(fromone,'/AreaChart').replace(fromtwo,'area_chart.php').replace('index.php','area_chart.php');
} else if (aothis.innerHTML.toLowerCase().indexOf('bar') != -1) {
if (dccnt != 0) topmou='BarChart/bar_chart.php';
returl=returl.replace(fromone,'/BarChart').replace(fromtwo,'bar_chart.php').replace('index.php','bar_chart.php');
} else if (aothis.innerHTML.toLowerCase().indexOf('column') != -1) {
if (dccnt != 0) topmou='ColumnChart/column_chart.php';
returl=returl.replace(fromone,'/ColumnChart').replace(fromtwo,'column_chart.php').replace('index.php','column_chart.php');
} else if (aothis.innerHTML.toLowerCase().indexOf('line') != -1) {
if (dccnt != 0) topmou='LineChart/line_chart.php';
returl=returl.replace(fromone,'/LineChart').replace(fromtwo,'line_chart.php').replace('index.php','line_chart.php');
}
postgoother(returl);
return returl;
}document.getElementById('thedivoverlay').innerHTML='<iframe id=thedivoverlayi name=thedivoverlayi style="opacity:<?php echo $op; ?>;z-index:9;position:absolute;top:<?php echo $tpy; ?>px;left:<?php echo $lfx; ?>px;width:' + eval(rect.right - rect.left) + 'px;height:' + eval(rect.bottom - rect.top) + 'px;" src="' + 'about:blank' + '"></iframe>';
- set yourself challenges starting with a “Hello World” such as creating a PHP webpage in the three ways above that shows “Hello World” at a url such as HTTP://localhost:8888/hello_world.php
- where?
- 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)
- best online webpages start at “the home of PHP”
- we like the books
Professional PHP Programming by Jesus Castagnetto (ISBN: 1-8610029-6-3),
PHP and MySQL Web Development by Luke Welling and Laura Thomson (ISBN: 0-6723291-6-6),
The PHP Anthology (Volume II: Applications) by Harry Fuecks (ISBN: 0-9579218-4-5)
- when?
… try PHP today!
If this was interesting you may be interested in this too.