Good Bye From Geeks On PHP

It has been a long time (far too long) since we let everybody know what is going on with Geeks On PHP so here I am to do exactly that. Due to some scheduling issues and unforeseen events Stephen and I have decided to disband the Geeks On PHP podcast. We had a great time bringing you weekly discussions on PHP, web development, databases and everything in between.

I recently started a new project called TweetPHP which is a web site and podcast focused on collaborative PHP development. We are using github to host our codebase and allow users to fork off their own copies of the repository and add/modify/contribute. If you are interested in a podcast focused on PHP and were still waiting for the OOP series then I urge you check out TweetPHP as we will be discussing object oriented programming in our next episode.

I will still be contributing to For the Love of Geeks in the form of blog posts and helping maintain the twitter account. If you are interested in seeing what else I am up to please check out http://nicholaskreidberg.com.

Thanks,

- Nicholas

Share

Read Users' Comments (2)

Geeks On PHP OOP Update

I want to give everybody a quick update on what is going on with Geeks On PHP and what to expect in the near future. As we talked about on our last episode we are putting together a series of podcasts focused on OOP in PHP. Unfortunately due to time constraints, work overload and other things out of our control we have had to push things back a bit. The series is still going to happen and we are excited to have Mitchell Hislop who is a friend of mine and a very talented developer / social media expert joining us for the series.

As soon as we are able to settle on dates to record I will provide updates via Twitter and our Facebook page letting people know what to expect. Thank you for your patience and we look forward to releasing a great series on OOP!

Follow both Stephen & Myself on Twitter and also subscribe via Tunes.

- Nicholas

Share

Read Users' Comments (9)

Geeks on Doctor Who : Episode 2 : Vincent and the Doctor

This week Janet joins us, but Vinita seems to have been taken on an adventure with the Doctor .. we are confident that he will return her before our next episode..

This week we start our recaps with Vincent and the Doctor .. we struggle with the pronunciation of Krafayis and wonder about how to pronounce Van Gogh ..

We talk about Time travel and the moral ramifications of changing the future as well as the wonderful validation that comes with being able to head several hundred years into the future to see how your work affected history.

Enjoy the show, and remember .. don’t blink

Audio clip: Adobe Flash Player (version 9 or above) is required to play this audio clip. Download the latest version here. You also need to have JavaScript enabled in your browser.

want to listen on your mobile device? [ Direct Link ]

Share

Read Users' Comments (1)

Geeks On PHP Episode 14

This week Stephen and I talk about user defined functions in PHP and why they matter. This is a precursor to our upcoming series on OOP in PHP.

Functions are the key to reusable code and thus should be used as often as it makes sense. Duplicating code is a big no no and should avoided at all costs, this is where functions come into play. Just last week I was working on a script that pulled back two different data sets (as arrays) and needed to do essentially the same thing to these two sets. Rather than duplicate the code twice I just converted my logic to a function and boom I was off an running with no duplication what-so-ever.

function fnXML_Body($adata)
{
  $sxml_body = NULL;
  $i = 0;
  foreach($adata as $arow)
  {
    foreach($arow as $svar=>$sval)
    {
      switch($svar)
      {
        case "slabel":
          $slabel = $sval;
          break;
        case "ivalue":
          $ivalue = $sval;
          break;
      }
      if($i < 2)
        $sslice = "isSliced=\"1\"";
      else
        $sslice = NULL;
    }
    $sxml_body .= "\n";
    $i++;
  }
  return $sxml_body;
}

Using the function above I can call pass a new data array to it as many times as I need to in a script without duplicating any code. The function accepts the data array, does some parsing and returns the XML that I need to generate a 3D Pie Chart.

The call to this function would be as follows:

  $sxml_body = fnXML_Body($adata);

In the next couple weeks we are going to kick off a series on object oriented programming with PHP which will include all the basics as well as the tools needed to build a small web application from start to finish. We will be featuring a special guest for this series, it’s going to be very exciting and something you definitely don’t want to miss.

Follow both Stephen and Myself on Twitter and also subscribe via Tunes!

Enjoy the show and as always, stay geeky!

Audio clip: Adobe Flash Player (version 9 or above) is required to play this audio clip. Download the latest version here. You also need to have JavaScript enabled in your browser.

- Nicholas

Share

Read Users' Comments (1)

Geeks On PHP Episode 13

This week Stephen and I talk about strings and how they are accessed, manipulated and used in PHP.

We kick off the discussion talking about some differences between echo() and printf(). Below is an example of using both functions to populate a text field on a web form. We will start off with using echo():


.. input type="text" name="foo" id="foo"
[Inside PHP Block]
if(!empty($dbresult['foo']))
echo ' value="'.$dbresult['foo'].'" />';
else
echo ' value="" />';
?>

Here is the same end-result using printf():


... input type="text" name="foo" id="foo"
[Inside PHP Block]
printf(" value=\"%s\" ", !empty($dbresult['foo']) ? $aResults['foo'] : "");
?>

I tried to make the “argument” during the show that printf() allows for a lot more flexibility as well as resulting in slightly more compact code. Notice the usage of PHP’s ternary operator in the printf() example. It allows for a great deal of flexibility and power directly in-line w/ your output statement.

Regular Expressions were also a big topic of discussion this week and as promised here are some examples of commonly used RegEx’s in web application development:


$pattern_date = '#(0[1-9]|1[012])[- /.](0[1-9]|[12][0-9]|3[01])[- /.](19|20)\d\d#';
$pattern_email = '#^[a-zA-Z._]+@[a-zA-Z_]+?\.[a-zA-Z]{2,4}$#';
$pattern_email2 = '#^\w+([\.%-]\w+)*@\w+([\.-]\w+)*(\.\w{2,})+$#';
$pattern_phone = '#^(?:\([2-9]\d{2}\)\ ?|[2-9]\d{2}(?:\-?|\ ?))[2-9]\d{2}[- ]?\d{4}$#';
$pattern_time = '#(1[0-2]|[1-9]):([0-5][0-9])#';
$pattern_url = '#(http|https)\://[a-zA-Z0-9\-\.]+\.[a-zA-Z]{2,4}(/\S*)?$#';
$pattern_alphanum = "#^[a-zA-Z0-9\s]+$#";

To test matching on these patterns you can simply use the preg_match() function:

preg_match($pattern, $string, $matches);
if(!empty($matches))
    print_r($matches);

A couple of my favorite resources for regular expressions are:
The Online Regular Expression Testing Tool
The Regular Expression Library

Regular Expressions provide so much power and versatility when it comes to pattern matching and replacements that they just can’t be ignored. If you have questions about any of the above please let us know.

Follow both Stephen and Myself on Twitter and also subscribe via Tunes!

Enjoy the show and as always, stay geeky!

Audio clip: Adobe Flash Player (version 9 or above) is required to play this audio clip. Download the latest version here. You also need to have JavaScript enabled in your browser.

- Nicholas

Share

Read Users' Comments (1)

Geeks On PHP Episode 12

In this episode Stephen and I talk about database connections, retrieving results and making use of those results. Both MySQL and PostgreSQL are discussed in this episode so whichever open source database you are using we got you covered.

Here is a link to Stephen’s database class for MySQL. He discusses it’s usefulness and some of it’s functions in the show.

Here is some sample code for getting connected to and pulling out results from a PostgreSQL database. The database include file should be separate from your application code so that you can easily change connection parameters in one location without touching your application.

/* Example of PostgreSQL database include file
	named db.inc */

$host = "hostname";
$port = "port";
$dbname = "database";
$dbuser = "username";
$dbpass = "dbpass";

$hdb = pg_connect("host=$host port=$port dbname=$dbname
	user=$dbuser password=$dbpass");

/* How to include and open connection in script */
require_once("db.inc");

/* How to query a PostgreSQL database */
$res = pg_query($hdb, "SELECT name, email FROM table");

/* Close database connection */
pg_close($hdb);

/* Create associative array */
while($ares = pg_fetch_assoc($res))
{
	// do stuff
}

/* Create object */
while($ores = pg_fetch_object($res))
{
	// do stuff
}

Check both Stephen and Myself out on Twitter and also subscribe to us on iTunes!

Enjoy the show and as always, stay geeky!

Audio clip: Adobe Flash Player (version 9 or above) is required to play this audio clip. Download the latest version here. You also need to have JavaScript enabled in your browser.

- Nicholas

Share

Read Users' Comments (2)

Geeks On PHP Episode 11

In this episode we talk about everything from image manipulation, generating charts & graphs, classes and frameworks and even home invasions.

The charting libraries I discuss are Fusion Charts and pChart, both are very good libraries and have great documentation on how to get started.

The following is a code snippet that I wrote which takes in an associative array, parses it out for a data label ($a[0]) and a data value ($a[1]) and generates a Fusion compatible XML file.

function fnGenerateXML($scaption, $sxaxis, $syaxis, $adata)
{
  if(empty($adata))
    die("Empty data set passed to function.");

  $sdata = "\n";

  foreach($adata as $arow)
    $sdata .= " \n";

  $sdata .= "";

  $sfile_xml = "./chart.xml";
  file_put_contents($sfile_xml, $sdata);
  return $sfile_xml;
}

The function is called in the following fashion:

$sfile_xml = fnGenerateXML("Caption", "X Lbl", "Y Lbl", $a);

The Fusion Chart is generated using the following method call:

echo renderChartHTML("./Column3D.swf", "$sfile_xml", "",
      "ID", 650, 650, false);

Here is some sample code I wrote to generate a graph using pChart:

// Dataset definition
$pData = new pData;
$pData->AddPoint($a1, "s1");
$pData->AddPoint($a2, "s2");
$pData->AddPoint($alabels, "lbl");
$pData->AddSerie("s1");
$pData->AddSerie("s2"); 

$pData->SetSerieName("s1lbl", "s1");
$pData->SetSerieName("s2lbl", "s2");
$pData->SetYAxisName("Ylbl");

$pData->SetAbsciseLabelSerie("lbl");

// Init graph
$pGraph = new pChart(800, 340);
$pGraph->setFontProperties("./tahoma.ttf",8);
$pGraph->setGraphArea(50,30,680,200);
$pGraph->drawFilledRoundedRectangle(7,7,693,240,5,240,240,240);
$pGraph->drawRoundedRectangle(5,5,695,240,5,260,230,230);
$pGraph->drawGraphArea(255,255,255,TRUE);
$pGraph->drawScale($pData->GetData(),
   $pData->GetDataDescription(),SCALE_ADDALL,150,150,150,TRUE,0,2,TRUE);
$pGraph->drawGrid(4,TRUE,230,230,230,50);

// Draw the 0 line
$pGraph->drawTreshold(0,143,55,72,TRUE,TRUE);

// Draw the graph
$pGraph->drawStackedBarGraph($pData->GetData(),
   $pData->GetDataDescription(),TRUE);

// Finish
$pGraph->drawLegend(500,40,$pData->GetDataDescription(),255,255,255);
$pGraph->drawTitle(225,22,"Title",0,0,0);
$pGraph->Stroke();

As you can see pChart requires a bit more setup to get going but both are great libraries for getting the job done. Another free option for charting/graphing that we didn’t discuss on the podcast is the Google Chart API.

Check both Stephen and Myself out on Twitter and also subscribe to us on iTunes!

Enjoy the show and as always, stay geeky!

Audio clip: Adobe Flash Player (version 9 or above) is required to play this audio clip. Download the latest version here. You also need to have JavaScript enabled in your browser.

- Nicholas

Share

Read Users' Comments (1)

Geeks On PHP Update

Hey everybody, I just wanted to let you know that I have been out of town for a few days and wasn’t able to find time to record last weeks show. I apologize for the unannounced delay and want to let everyone know that we are set to record this Wednesday and I will make it a point to get the episode out ahead of the usual Sunday release. If you are wondering what I was up to you are welcome to check out my latest Flickr set.

Thank you for your patience and I will let everybody know via the usual channels when Episode 11 is available.

Thanks,

- Nicholas

Share

Read Users' Comments (1)

Geeks On PHP Episode 10

We are happy to bring you episode 10 of the Geeks On PHP Podcast!  This week we talk about API programming, specific API’s that we have worked with, some great development tips and even alcohol.  This episode has it all.

The Authorize.net API comes up a bit in discussion and I mention the article I wrote a couple of days ago regarding some changes to online debt card processing as it pertains to the Authorize.net API.

We invite you to follow both Stephen and I on Twitter and also subscribe to us on iTunes!

Enjoy the show and as always, stay geeky!

Audio clip: Adobe Flash Player (version 9 or above) is required to play this audio clip. Download the latest version here. You also need to have JavaScript enabled in your browser.

- Nicholas

Share

Read Users' Comments (0)

Geeks On PHP – Episode 9

After a long wait, Geeks on PHP – Episode 9 is finally out!  As I mentioned in a previous post we are now on a weekly recording schedule and will be releasing a new episode every Sunday evening unless otherwise specified.

In this exciting episode we discuss lots of information and things to think about *before* you start building your database or writing your application.  We also touch on SQL statements, database schema design and how they relate to your PHP applications.

Audio clip: Adobe Flash Player (version 9 or above) is required to play this audio clip. Download the latest version here. You also need to have JavaScript enabled in your browser.

Also, subscribe to us on iTunes and leave us your comments: [ Launch iTunes ]

Follow us on Twitter :
Nick : http://www.twitter.com/niczak
Stephen : http://www.twitter.com/darthweef

- Nicholas

Share

Read Users' Comments (0)

 Page 1 of 2  1  2 »