SAC

SAC

Saturday 9 January 2010

The Evolution of a PHP Coder

Sometimes it baffles me to see so much PHP bashing coming from .net coders, some of them aiming their hate towards the language itself, but some others to the coders. I must admit PHP is not the cleanest language you will find out there and I must admit PHP coders are not the elite of the coding world, but there is a reason for this: PHP is accessible.

This means anyone can grab a php script and tweak it, anyone can code a blog or photo gallery script without much effort with basic php knowledge, and the best of all, it costs nothing. No need to spend money on IDEs, compilers or servers, just install apache, php and mysql and get the job done. It is reasonable to think that most newbie coders in the market are working with the most accessible tools, that means, you have higher chances of finding a php newbie than a .net newbie, and this gives us all bad reputation.

But not all of us are or will be newbies forever, some of us make a career working on the web development industry and hey, some of us are good at it! If you need a demonstration of this, I can show you how I have been writing code during the 6 or 7 years that I have been doing it.

First year



//Login script
if($_GET['user']=="jack" && $_GET['password']=="WelcomeToTheBackend"){
  header("location: admin.php?loggedin=1");
  exit();
}


//Admin script
if($_GET['loggedin']==1){
  ?> ... display administration console here ... 


Second year



//Login script
$user = $_POST['user'];
$pass = $_POST['password'];
mysql_connect("localhost","root","");
mysql_select_db("mydb");
$r=mysql_query("select * from users where username='$user' and password='$pass'");
if(mysql_num_rows($r)){
 header("location: admin.php?loggedin=1");
 exit();
}


//Admin script
if($_GET['loggedin']==1){
  ?> ... display administration console here ... 


Third Year



//Login script
$user = $_POST['user'];
$pass = $_POST['pass'];
$sql = new SQLClass();
$sql->connect();
$sql->query("select * from users where username='$user' and password='$pass'");
if(count($sql->res)){
  $_SESSION['user'] = $sql->res;
  header("location: admin.php");
}


//Admin script
if(!$_SESSION['user']){
  exit();
}


Fourth year



//Login script
$user = SecurityClass::validate($_POST['user']);
$pass = SecurityClass::validate($_POST['pass']);

$user = new UserClass();
$user->authenticate($user,$pass);
$system->redirect("admin");


//Admin script
if(!UserClass::userAuthenticated()){
  exit();
}


The point I'm trying to make is, anyone can code in PHP, even idiots like me.

But it takes time to get a professionally acceptable level, a level at which you can measure yourself with coders from other platforms and you can get competitive. Other more strict platforms usually require more experience and skills to begin working with them and that could be a good thing to keep a decent level in the community but it does not make the language or the coders necessarily better.

So you, puny PHP coder reading this blog, if you ever get bullied by the big boys, put in the drive that old CD where you store the older projects, see what you wrote when you started, get scared a bit and then see how much you have improved over the last few years.

Soon you will understand that knowledge and growth are much more valuable than a compiler and an IDE license.

2 comments:

k said...

haven't we all started like this?!

I remember the old days when I started to learn PHP...I only had very little OOP knowledge and all the example I could find then were just using functions over functions so I copied the model and start doing those examples...

Then I started to learn more about OOP and everything just got clearer :)

I find it "very" difficult right now to start writing some code without using the OOP way. You may say that I'm an OOP addict :))

Suyash Dwivedi said...

Wow Seriously Dude Quite an Improvement Php looks a little messy to me But if to take the example of yours, i will improve in the course of time