Archive for the ‘Beginners PHP Articles’ Category

How important is the choice of programming language – in app creation?

Monday, April 14th, 2014

Hi,

I am a big advocate of PHP but you have to ask yourself, how important is the choice of programming language, given so many great apps are created with many different languages? Think about it:

  • Twitter – created with Ruby
  • Facebook – created with PHP
  • LinkedIn – created with Java

I get deeper into this topic in this video blog:

Thanks,

Stefan Mischook
killerPHP.com

Why PHP should be the first language you learn.

Thursday, February 13th, 2014

Yo!

Anyone who reads my stuff knows that if I am anything, I am practical. So when it comes to learning (and teaching) programming to someone new to the whole programming game, for several pragmatic reasons, I think PHP by far is the best language to begin with. Here are some of the reasons:

  • It is easy to learn.
  • It is the most popular web scripting language.
  • It is fast to program with.

Now, you can watch me yap about this in video for about 5 minutes – enjoy!

Thanks,

Stefan Mischook
killerPHP.com

Denial-of-service attack … in an image.

Monday, May 20th, 2013

Hi,

Not strictly PHP but something that any web programmer might have to deal with from time to time: denial-of-service attack (DoS attack).

What is a DOS attack?

Some dirty nerd (or group of dirty rat bastard nerds) decide they want to make your site or your servers unusable or at least, much less usable. What they do is flood the server with request in attempt to overload the CPU, memory and bandwidth.

… It just happend to me here on the killersites.com/killerphp.com servers. Some jerk-store using a microsoft server out of Washington, started flooding our PHP based forum with request … millions a day in fact! We have a fairly new dedicated server with multi-core processors, so we did not go down, but the server did get noticeably slower.

How did I discover it?

Besides noticing the server was acting a little sluggish (kinda like me after a few beers,) I popped open the web stats and noticed a huge amount of traffic from one IP address – that isolated source of big traffic pretty much tells you what you need to know.

How do you fix it?

Well, a good firewall is supposed to catch these things and block them … it seems my firewall falls asleep on the job sometimes, so in this case, I had to manually go in and ban the IP address. Once banned, any request from that IP are just dropped. This is not a perfect solution since the nefarious nerds can then just switch IP’s to continue the attack … but it seems to have done the trick this time.

Check out the chart below, showing the KillerSites server traffic flow, before and after I blocked the attacker’s IP:

DOS attack

Thanks,

Stefan Mischook
killerphp.com

How PHP Frameworks Can Go Bad

Friday, May 3rd, 2013

Hey guys. My name is Roberto and I have been a web developer for the past five years. I will be blogging about interesting things in the life of a developer

I have worked with a few different frameworks over the course of my development career (e.g. CodeIgniter, Laravel, Symfony) and have also tried/tested many others. I always felt that frameworks are these perfect libraries of code that will make my life easy, and generally, that has been the case.

But over the last few months, I realized that frameworks are not perfect. Not even close. And although they do make annoying things like form validation or URI routing super easy, it seems that the simplest things can become buggy or complex.

No framework is perfect

Case and point: I have been working on a pretty decent sized project using CodeIgniter (my 4th project using this framework). CodeIgniter seems to be everyones “first”. The first framework where beginner PHP developers learn important skills like OOP and MVC.

But as I said, things are not perfect.

I kept getting some weird behaviour with PHP sessions, specifically when logging in and out in IE (insert IE insult here). It took me a few hours to solve the issue, mainly by partly rewriting some third party session library. But I felt it was really weird that something as simple as PHP sessions was broken (I mean there aren’t even that many PHP sessions functions)

So whats the point…

I basically have two main points:

  • Frameworks are not perfect libraries of code that will make developing a breeze. They definitely do help (without a doubt), but dont be surprised to find bugs that will take you more than a few hours to fix.
  • Saying that, fixing these bugs actually helps you become a better developer. It gets you to get into the smaller details and overall you learn much more about developing in PHP

When developing somewhat complicated web apps, I think using a framework is almost a must. Choosing a framework on the other hand…thats for another day.

For more discussion, you can find me on twitter here

Learning PHP: going beyond the basics

Sunday, June 3rd, 2012

Learn PHP by Building Web Applications

Once you have an understanding of basic PHP concepts, the best way to develop your skills further, is to actually start building PHP applications – things that actually do something!

Fortunately, the Web has matured much in the last decade, and we now know what types of applications people are typically looking for – things like:

- shopping carts.
- log-in systems.
- content management systems.

With that in mind, we’ve put together a package that teaches you how to build these things, while teaching you more advanced PHP.

What’s really cool, is that once you’ve completed the project courses, not only will you have learned a lot about creating REAL PHP applications, you will have these applications that you can then use in your own projects, or your client’s projects. Check it out:

PHP Projects – Learn PHP by Building PHP Applications

Thanks,

Stefan Mischook
killerphp.com

Android and iOS Development – the easy way!

Tuesday, February 15th, 2011

Hi,

I’ve been getting a lot of emails lately that are kinda like this:

Stef, I want to learn how to create apps for iPhones, iPads and Android devices … can you teach me!

Well the good news is that I am looking into this now. The bad news is that I don’t have anything ready … yet. That said, I do have some useful information and strategies for people who want to jump on this bandwagon quickly and easily.

Listen up …

iOS is for iPhones and iPads

That means you need to learn objective C … if you want to have total control over the iOS device. More on that later.

Google’s Android – on phones and tablets.

That means you need to learn a subset of Java (basically stripped down Java) if you want to have total control of the devices.

About objective C and Java

I don’t know much about objective C (but I’ve heard things …) but I do know a lot about Java. In both cases, many junior level PHP programmers might have a hard time with these languages because they require a deeper understanding of OOP.

The solution: HTML 5 and CSS3

The great thing about mobile applications, is that we expect that most of the time, they will be connected to the Internet – we assume that the apps will interact online at some point if not all the time.

This opens up the possibility of moving some of the heavy lifting over to the server where PHP can take care of biz for you. This MAY minimize the need to have to go down to the core of the device, forcing you to use Java or Objective C … depending on the device of course.

In the meantime, you can use HTML 5′s nifty new ability for local storage (of files,) to handle the times when a smart-phone is NOT online. How often does that happen …?

Stefan Mischook
killerphp.com

Password Protecting Pages with PHP

Saturday, January 29th, 2011

password protect pages with php

Hi,

I recently got an email asking how to create password protected pages .. in an easy fast way for a beginner to PHP. From the email:

I was wondering if there is some premade script and setup for database I can utilize to get this up faster and still proceed to educate myself.

As any experience PHP nerd knows, there are several approaches one could take. But since this guy is new to PHP and programming, I decided on something simple:

(more…)

Killersites Community Blog – Basic PHP System: View, Edit, Add, Delete records with MySQLi

Monday, December 6th, 2010

Forum
Hey Everyone,

Here’s some helpful info on a basic PHP system, from our Killersites Community Forum!

Basic PHP System: View, Edit, Add, Delete records with MySQLi

This is a revised version of my previous tutorial (http://www.killersit…eteadd-records/) which uses MySQLi rather than regular MySQL to connect to the database. MySQLi, often called MySQL Improved, has several advantages over regular MySQL, including support for prepared statements (which helps prevent SQL injection, a common security issue) and object-oriented code. I’ve also provided a modified view.php file that shows one way to do basic pagination.

I have also recorded a 8 part video tutorial (a bit over an an hour worth of video) showing how to build this system and explaining it as I go. It’s available in the KillerSites University (http://www.killersites.com/university – subscription required) under PHP > PHP CRUD Videos.

(Anyone with PHP knowledge is welcome to comment on the code. If there are issues I haven’t noticed, please let me know. Do realize that it is intended for beginners, so I didn’t want to do anything too advanced that might lead to confusion. Yes, I realize I could use OOP, or could separate some of these out into methods, etc. etc.)

OK… Here’s some code for you to play with. It’s a basic system that allows you to:
– view existing records
– edit existing records
– delete existing records
– add new records

Online demo:

http://www.falkencre…mysqli/view.php

Basically, just imagine that you are in charge of a sports team, and you want to keep a list of all your player’s contact information. The code I’ve created could be a starting point for that (it only includes fields for their first name/last name, but could obviously could be expanded to use more fields).

This is just a basic starting point for projects that require view/edit/delete functionality. I know it may seem a lot to understand at first, but read all the comments in the code — I try to explain what I am doing step by step. I’m also happy to help with any questions (please post questions in a new topic.)

How to create a system that allows a user to add/edit/remove data in a database seems to be a commonly asked topic, so I may adapt this into an actual tutorial at some point in the future.

DATABASE:
– You’ll need to create a database (I named mine ‘records’ but it can be changed) using PHPMyAdmin
– Save the included sql file on your desktop as a .txt file
– Once you’ve created the database, make sure the database is selected, then click the “import” tab
– Select the .txt file on your desktop, and import it into your database. PHPMyAdmin will create all of the necessary tables/import some test data for you to play with

Written by: Ben

For the test data and the rest of the post, click here!

Thanks,

Jody
Killersites.com

Learning Java OOP gently …. through PHP!

Thursday, November 18th, 2010

Hi,

Some of you may know that I am an old Java programmer … big into POJO’s and I loved servlet filters. Those days are long gone now (for a whole host of reasons) but I still clearly remember how hard it was for me to learn Java. It could have been much easier though!

Learning OOP Java easily through PHP

If you already know OOP from another language, then by all means, jump right into Java … you should have know problems. If on the other hand you are like I was, where you don’t understand OOP yet or you haven’t even programmed before, do yourself a big favor and learn the principles of OOP (object oriented programming) with a much easier to understand language like PHP.

… Yes, PHP doesn’t look a lot like Java but the OOP constructs and principles are the same. Except with PHP, it is much less complicated. I won’t get into the specifics why, but let’s just say Java makes you do a lot more work to get the same things done as compared to PHP.

When Learning to fight, better to start with an easier opponent.

Besides getting my nose broken 3 times, boxing taught me that when you are first learning to fight, it’s a good idea to not get into the ring with Mike Tyson. Otherwise you will probably get knocked out and you might even get your ears bitten off.

The same is true for learning object oriented programming; better to learn this style of programming with an easier to understand (and use) language like PHP, instead of Java – the Mike Tyson of languages.

Where to learn OOP programming?

So if you think what I say makes sense, then head over to my very popular, super easy to understand FREE lessons on PHP and OOP.

… I’m sure many Java wannabe’s will find the lessons useful.

See you on Live!

Stefan Mischook
www.killerphp.com

Complete Web Programmer vs. Complete PHP Programmer?

Monday, November 15th, 2010

I got an interesting email question today:

As ever I am always planning ahead. Since I am now half way through your Complete Web Designer course I am looking to complete the Complete Web Programmer next.

But I have noticed the Complete PHP Programmer also. Looking at the modules these seem quite alike. Has one replaced the other? Which one is better suited to the beginner (me) and why?

Hi Mick,

The Complete PHP Programmer has the same content as the Complete Web Programmer minus the Javascript and JQuery material.

We added that course because some people only want to learn PHP. I recommend the Complete Web Programmer if you want to become a web programmer though, since Javascript is so central these days to dynamic websites.

Mick continues …

Im still thinking of purchasing your HTML5/CSS3 DVD first and getting the best grasp of HTML/CSS before branching out, but I like to plan ahead also. I aim to get through all of your courses that are relevant to myself at one point and as such trying to work out a rough order.

The order of learning things, is ultimately a personal thing. That said, I generally believe that learning the basics of the big four is first priority:

1. HTML
2. CSS
3. PHP
4. Javascript

… I would then move on to HTML 5 and CSS 3 simply because they are still niche technologies … growing, but still niche.

Stefan Mischook
killerphp.com

PHP Programming: 1 part code, 2 parts testing.

Sunday, November 14th, 2010

Any programmer with more than 3.2 days of experience knows that programming has a lot more to do with testing than coding.

Most errors in software are human related – typos, failed attempts at logical-construct construction etc …. This knowledge make two things clear:

1. Using proven frameworks or libraries (like Zend, CodeIgniter, PHPCake etc) will save you a lot of time and you will end up with more robust applications since the framework’s codebase will be cleaner than a from scratch solution you create.

2. Testing should be significant part of the regime – test and retest, I like to say. I would even suggest a testing protocol be put in place (unit testing on the object level can make sense) where with each update to the codebase, a series of related test of the application is initiated.

How Simple Errors Can Cause Big Problems

We’ve recently been updating the shopping cart system on killervideostore.com and I found errors creeping into the application that prevented some buyers from actually buying product … this is a problem for a store!

:(

The funny thing is, that the problem was a simple UI bug (simple CSS fix for IE) that pushed buttons out of view and so the buying process was made impossible. A simple retest of the UI on all the major browser before publishing would have been a good idea IMHO.

… That’s the funny thing about bugs, they show up where YOU DON’T EXPECT THEM.

Stefan

Perl Programming in the Modern Web?

Monday, November 8th, 2010

Hi,

It has been a while since I’ve written an article on killerPHP … and so it’s time for another one of my inflammatory articles!

Before I begin, I should point out that I’ve written articles so vexing to other geeks out there, that it caused them to quit other sites and flame wars so brutal developed, that threads had to be closed and apologies issued.

Fortunately, this little article on Perl’s place in the modern Web will only mildly annoy a few old-school Perl nerds. Yes, click on the link just above to read it … I don’t want to post it twice.

Thanks,

Stefan Mischook.
killerphp.com

Three good PHP IDE’s … that’s ‘nerd’ for PHP Programs

Monday, September 20th, 2010

Hi,

So you want to write PHP code but you are not sure what program to use? Well, there are many options out there for PHP nerds (which is good) but again, which one to use?

Many times, this comes down to personal taste and I don’t know all the options out there … so I will limit it to three:

http://netbeans.org/features/php/

From the Netbeans site:

The NetBeans project offers a version of the IDE tailor-made for developing PHP web sites that comprise a variety of scripting and mark-up languages. The PHP editor is dynamically integrated with HTML, JavaScript and CSS editing features.

Focus on the code and speed up code scanning by excluding individual directories in the Project properties. The NetBeans IDE fully supports iterative development, so testing PHP projects follows the classic patterns familiar to web developers.

http://www.eclipse.org/downloads/

http://www.adobe.com/products/dreamweaver/

I encourage you to try all three options and see what you prefer. Netbeans and Eclipse are more for programmers and have very powerful tool sets in that regard (that means they have all the bells & whistles) but for web designers getting into PHP, Dreamweaver maybe the choice.

… OK, Dreamweaver is not the best at PHP and I would probably not recommend it for hardcore PHP application development. But if you are building small to medium sized PHP applications, then it can more that handle the job with its’ basic code hinting, macros etc.

Stefan

My Killer PHP Learning Tips

Thursday, September 3rd, 2009

php logo

Hi,

Learning to program can be a frustrating process for a lot of people; especially for designer types wanting to learn a little PHP. The following tips should help a lot of you along the way to becoming a PHP nerd. My PHP learning tips:

1. Be patient:

Patience is a virtue, especially when learning to program. Don’t be discouraged if something doesn’t sink in right away. It will come with time.

2. Learn to write code on faith:

… That means writing PHP code that you may not fully understand. The process of actually writing out the code, seems to help the brain take it in.

3. Learning PHP programming is a lot like learning a sport; you can pick up stuff by sitting on the sidelines and watching, but you don’t really know what you’re doing until you actually get into the game. In PHP, that means actually writing code and not just sitting listening or reading about it.

4. Take a breather:

If something is not sinking in right away, move on to something else and come back to it later … actually, give it 24 hrs to sink in. I find that the brain will work on problems over night and almost magically, things that you could not understand the day before, will become obvious.

5. Try variations in your code:

Play with different ways of doing things, try to add variation to your code. If for instance you are learning something as simple as a conditional statement .. like the ‘if’ statement, try some examples with mathematical equations and then maybe try something using a function that returns a true/false value.

6. Break your code:

One of the best ways to learn any programming language is to purposefully break code. Why? Basically it comes down to seeing what type of error messages you get for certain types of mistakes in your code. In time, you will see that particular errors will give you consistent error messages. Once you know these, debugging code will be a lot easier.

I’ve found that breaking things on purpose and in a controlled manner, can really help down the road when you run into real errors, because you will recognize the error messages.

PHP vs. Perl vs. Java – a student’s question.

Monday, August 17th, 2009

Once and a while, I get a question from a student about PHP and programming that I use in a blog post … here we go again:

… you mentioned that you used to use mostly Java but have switched to mostly PHP. Would you recommend learning PHP as a primary method of creating dynamic web pages or is its strength in data base manipulation. I was learning Perl form processing which led me to your site when I was having trouble with mySQL, and I noticed PHP is very similar (at least in the basics) as Perl. Do you have much experience in using Perl to help create web pages and would you recommend using it at all?

About PHP vs. PERL vs. Java:

PHP is the way to go. Perl is a good language but it was not designed initially for web development – that functionality was added later.

Whereas PHP (which borrows from Perl btw) was designed specifically for web development, and so Perl is just clunkier compared to PHP when it comes to creating dynamic web sites.

I’ve used Perl in the past, mostly creating simple string parsing scripts and other little things. But I would NOT call myself an Perl programmer – so take that into consideration.

That said, I’ve always liked a common strategy used in Perl, where they generate static pages from dynamic code. For example, in our web designers directory, I used a Perl based directory script that uses that strategy.

… What’s interesting is that it generates the directory pages as static HTML pages. The advantage of this is that the directory itself is more portable and much less resource intensive because for the most part, the directory is just of pages that people just read … no need for them to be dynamically generated every time a user request it.

(more…)

Server Migration is Easy with PHP

Monday, July 13th, 2009

Recently we had to make an emergency move from our old servers (where we had been for 5-6 years) to our own dedicated server because of technical difficulties in the heads of the nerd’s who managed the servers killersites.com had been sitting on.

I will spare you the details of my server migration ordeal for now. What I want to point out, is that PHP (once again) has proven to be a great choice as the server side programming language.

PHP is consistent …

During this move, I had to deal with a bunch of web apps and scripts that included a nice buffet of technologies like:

- Perl
- PHP
- Java

.. Yes, the dreaded evil configuration hell that is J2EE!!

To make a long story short, migrating the PHP apps was a snap – copy over the files, set up the database and were off! On the other hand, I still have to get around to figuring out why the Perl and Java applications don’t want to run on the new server.

:(

PHP continues to rock, saving me time, money and headaches.

Stefan Mischook
www.killerphp.com

Programmers should learn to be language agnostic.

Monday, July 13th, 2009

In my last post I wrote about how Ruby’s early problems around 2006-2007:

- incomplete libraries
- difficult web server integration

.. had played a role slowing its adoption. The main thrust of the piece was to point out that despite the explosion of interest, Ruby and Rails had failed to make much of a dent relative to PHP in terms of usage. In fact, PHP is still far and away a much more popular language.

(more…)

PHP Video: always MySQL with PHP?

Wednesday, June 3rd, 2009

php video

Hi,

In this HD video (running time: 4:06), I answer a question put to me recently:

Should you always use MySQL as your database when working with PHP?

Yes, this is a beginners question, I know. Nonetheless, it is a legitimate question that I think is worthy of comment. In answering this question though, I briefly talk about the other database options you have with PHP.

The video:

MySQL with PHP

Note: I am using Youtube’s new HD streaming capabilities as an experiment. This is 720p video so you should have a fast connection to watch it, or some patience. If you find the video is stuttering, just press ‘play’, then pause it and then give it a minute or two to download.

Thanks,

Stefan Mischook

How to Build a Content Management System

Sunday, October 5th, 2008

OK, I just tricked you! This article is not going to teach you how to build a content management system with PHP from scratch.

Why not?

… Because building a content management system from scratch is (probably) a really dumb idea!! Now that I come to think about it, building any of the most commonly used software from scratch, is kinda stupid.

Things you should not build from scratch:

  • Content Management Systems
  • Blog Software
  • Forums
  • Directory scripts

The Top 3 Rules in Programming

The real estate business has a famous set of rules – the top three rules in fact:

  1. Location
  2. Location
  3. Location

The idea behind this rule, is to stress how important location is to a piece of property. In software development (programming), we have a similar set of key rules:

  1. Reuse
  2. Reuse
  3. Reuse

(more…)

SQL insert statements in PHP

Saturday, July 19th, 2008

Hi,

I’ve finally released my first video on using SQL statements in PHP pages. This is the next step after connecting to a MySQL database.

I hope you find the videos useful.

Stefan Mischook
www.killerphp.com

Created By Stefan Mischook  |  Top of page  go to top of page