Unthaw and Retry

Blogging, PHP+MySQL, WordPress 9 Comments »
Unthaw this Blog

Things are finally getting to a point of slowdown…somewhat anyway. Still very busy at work and at my personal business, but finally getting unburied to the point that I actually had time to write this. I do miss it, and there have been so many things happen and change. So many new blog start-ups, a lot of people struggling like me to find the time or post as often. I’ve done my best to still read here and there but I’ve really in the end have had to just read a few of the *favorites*.

So how do you unthaw a dormant blog, especially one this dormant? I’m not really sure to be honest. Hopefully I still have some of my good readers here and there.

Things to say or things I have not commented on yet:
No more Nice4Rice!!! Yeah, I know, its really old news by now, but I have not been blogging. That is definitely a blog I miss. I definitely understand Spud’s reasonings, but that type of article writing and his absolutely great reviews, I will sorely miss.

I do still plan on creating more PHP Hero cards. I am still a very active PHP programmer, although I have not been able to touch the notes in forever. I mentioned the next upcoming card being one to honor Ed, but then to go without creating one, what kind of a** am I? Just a busy one, I apologize. That will still be the very next card I create, and then, after that, you will see the very first PHP Hero card for a lucky lady…I can say no more…

I still struggle with keeping a blog that is a WordPress blog. It really makes no sense for a php developer to do so, I guess in the end it is just a convenience factor. A matter of convenience in regards to making it easy to post as well as just my pure laziness of not wanting to migrate to something else. Perhaps if I had more time I would look into the other options out there. WordPress really has the ability to be something so much greater, I really wish they would take in all the advice and ideas in a non-hostile manner. I definitely understand why WordPress is number 1 - I just wish the responsibility they have as being the most popular would lead them towards some very needed improvements.

My family is doing quite well. I have the greatest times with my Wife and kids. Really, every free minute has been going towards spending time with them. And it has definitely been the most valued moments in my life.

I hope all of you out there are doing great and if you are reading this, thank you very much for hanging out there, keeping subscribed, or just stopping by. I appreciate all of you probably more than you know.

9 Comments »

Terry Chay - PHP Hero

Heroes, PHP Friday, PHP the Language Cards, PHP+MySQL 1 Comment »
PHP the Language: Terry Chay

Its PHP Friday!
The PHP Friday Series

It is time once again for another PHP the Language playing card, the third of its kind. I really loved collecting trading cards way back when in my youth. So I decided that if PHP had a trading card game, perhaps the cards may look just like this. We honor our Baseball and Football heroes with collectible trading cards, lets do the same for our “PHP Heroes”. If there was such a thing as real cards, the people I create cards for are the ones I would try to track down and collect.

The PHP language has some excellent personalities backing it. One of the personalities that sticks out all the time to me is Terry Chay. I had heard his name originally as it was associated many times with Plaxo back when he still worked for them. But the first time I knew he was an Engineer I needed to keep an eye out for was when I heard about his OSCON presentation titled “The Underpants Gnomes Strategy Guide: An eCards Case Study”. Anybody with that kind of sense of humor is somebody worth listening to.

I am a subscriber of his blog and always look forward to his next post. His blog is always entertaining as he mixes in technical posts right along with everything else. He has a way with mixing in comical antics along with technical posts where he still comes across as an experienced developer, intelligent, and hilarious. You can tell that Terry is so passionate about what he does. These type of people are what make us and the PHP language itself so lucky to have.

Next planned PHP the Language Card: Ed “Funkatron” Finkler


“PHP the Language” Playing Cards Credits:
The overall card design is based off of the card playing game Magic the Gathering
“Poker” style cards have already been created - Check Them Out

Terry Chay Card Credits:
Original image located here: georges flicker

Terry Links From Card & Elsewhere:
http://terrychay.com/
http://terrychay.com/blog/

1 Comment »

PHP: Using switch() instead of if() + elseif()’s

PHP Friday, PHP+MySQL 3 Comments »

It’s PHP Friday!
The PHP Friday Series

It makes for much cleaner code if you use the switch statement rather than if() followed by multiple elseif() statements. I have read many performance tests articles and switch() does process faster over if() + elseif()’s. But how does it look? How do you code it? Well below are some examples.

First, lets set a variable just to have it as an example:

1
$example_var = 7;

Now in most apps, you have most likely seen something similar to the following:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
if ($example_var == 1) {
	// action 1 code here
}
else if ($example_var == 2) {
	// action 2 code here
}
else if ($example_var >= 3 && $example_var < = 6) {
	// action for 3 thru 6 code here
}
else if ($example_var == 7) {
	// action 7 code here
}
else {
	// for any other value do this
}

Those very same options can be coded into a more efficient switch() statement as follows:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
switch($example_var) {
	case 1:
		// action 1 code here
		break;
	case 2:
		// action 2 code here
		break;
	case 3:
	case 4:
	case 5:
	case 6:
		// action for 3 thru 6 code here
		break;
	case 7:
		// action 7 code here
		break;
	default:
		// for any other value do this
		break;
}

or as another switch() statement alternative that gives you an interesting perspective or way of looking at it:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
switch(true) {
	case ($example_var == 1):
		// action 1 code here
		break;
	case ($example_var == 2):
		// action 2 code here
		break;
	case ($example_var >= 3 && $example_var < = 6):
		// action for 3 thru 6 code here
		break;
	case ($example_var == 7):
		// action 7 code here
		break;
	default:
		// for any other value do this
		break;
}

As you can see by that last example, making the value in the switch() function to true or false and then loading switch cases that involve statements that are either true or not work just the same.

Summary:
So the variable enclosed in the switch() statement is what you are comparing its value to all the possible cases in the switch() statement that you have assigned. You assign each case a value or operation to see if its result matches the value of that variable. Everything located under that very case will be performed until it reaches the break statement letting it know to stop. Multiple cases can be brought together to all include the coding below it. It will keep performing all code below a matched case so long as a break statement is not met. default is the equivalent basically of just else. Its basically the “catch-all” and will always perform in the event that no other case above matched and had a break placed below it.

Definitely check it out over there on the wonderful packed full of information -> php manual:
PHP Manual: switch()

In the end, switch() may seem to be a little more difficult to code if you are not used to it, but if you look, it is a much easier code to read and know exactly what is going on. If the speed/benchmark tests that I have read about are true, than of course you want to use switch() as your primary function for this sort of coding anyway.

3 Comments »

Chris Shiflett - PHP Hero

Heroes, PHP Friday, PHP the Language Cards, PHP+MySQL No Comments »
PHP the Language: Chris Shiflett

Its PHP Friday!
Long ago, when I was discovering the language of PHP, I was very interested in finding out the security issues that I may come across and things I can do to prevent them. There is a name that is basically synonymous with security in PHP, and that name is Chris Shiflett. Chris wrote the O’Reilly book “Essential PHP Security” in 2005 which is often referred to in many security articles and posts. Chris has also contributed to many other PHP publications.

One of his biggest contributions to the PHP community is the PHP Security Consortium that he founded. This Consortium houses many key projects including the highly recommended: “PHP Security Guide” free to download and a must read.

I want to close this by saying, if you choose to code a web language, you need to take responsibility and learn how to code securely. Nobody is incapable of mistakes, but you need to absolutely do your best to code secure applications. Security needs to take the front seat and always be in your mind when coding an application. The first step to preventing bad code is education. Read articles, books, and warnings. There are many very common mistakes that you can educate yourself on how to prevent.


“PHP the Language” Playing Cards Credits:
The overall card design is based off of the card playing game Magic the Gathering
“Poker” style cards have already been created - Check Them Out

Chris Shiflett Card Credits:
Original image located here: georges flicker
Chris quote found here: RioSec: Chris’s Quotes

Chris Links From Card & Elsewhere:
http://www.shiflett.org
http://www.phpsec.org
http://www.brainbulb.com
http://omniti.com/people/bios/chris_shiflett

No Comments »

Rasmus Lerdorf - PHP Hero

Heroes, PHP Friday, PHP the Language Cards, PHP+MySQL 5 Comments »
PHP the Language: Rasmus Lerdorf

Quick Bio:
PHP started out as a personal project of Rasmus Lerdorf. Originally called “Personal Home Page Tools”, PHP’s first 2 versions were authored by Rasmus. Future versions have been core developed by many, but of course Rasmus is still well involved in development and the community. He is currently employed by Yahoo, an extremely PHP friendly employer. This offers him much opportunity to still be quite active in all areas that are PHP. He is constantly invited to conferences around the world. I have read and heard many times, if you choose to code PHP, you need to know the name Rasmus Lerdorf. You need to know PHP’s history and you need to know the man who originally brought it to us.

Being extremely security savvy, Rasmus decided to point out a security flaw in every single Open Source CMS program when invited to speak at OSCMS 2007. In a recent podcast, I remember hearing Ed Finkler, a key php securing developer and member of the PHP Security Consortium, saying that he would never show code around Rasmus, too scared what Rasmus would point out. Rasmus will not hold himself back anywhere when he sees a insecure application, it could be mid-conference and he will out you. I really like this about him, doing all he can to improve PHP’s overall security. For instance, if he ever commented on this post, he would probably tell me to stop using Wordpress ;) Wordpress is PHP based, but it has a wide and long history of bad coding and security flaws.

Rasmus was the first big name I heard in the PHP community when I started to get involved in it years ago. There are many big names now and loads of developers out there doing very important things, so I will be able to write many of these, but let us never forget this first one. Rasmus, the man who started it all! Thank you Rasmus!

Its PHP Friday!
The first here at my blog. In an effort to knock the dust off my blog, I wanted to create a standard that I will do my best to live by. Every Friday I will be posting some kind of PHP related post. It is only appropriate that the first PHP Friday post be on the first PHP developer. I have just been so incredibly busy working at work and home. However, what I am busy with is coding PHP. Because of this, I come across interesting PHP items all the time. As you know from my previous posts, the PHP movement and community means a lot to me. So I also have a lot of heroes in that community that I would like to write quick bios about and even create these silly cards for. Its been many years since, but as a young teen I was really into the card playing game “Magic the Gathering”. I thought these card layouts would be kind of a cool way to honor some of my PHP Heroes.


“PHP the Language” Playing Cards Credits:
The overall card design is based off of the card playing game Magic the Gathering
“Poker” style cards have already been created - Check Them Out

Rasmus Lerdorf Card Credits:
Original image located here: chrys flicker
Rasmus quote found here: Matt Wade Article

Rasmus Links From Card & Elsewhere:
http://www.lerdorf.com/
http://blog.360.yahoo.com/rlerdorf
http://toys.lerdorf.com/

5 Comments »
"Reformatted", but based on a WP Theme & Icons by N.Design Studio
Entries RSS Comments RSS Login
Close
E-mail It