13 Replies - 6672 Views - Last Post: 01 June 2011 - 11:48 AM Rate Topic: -----

#1 thomas130  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 20
  • Joined: 04-March 11

What the best way to learn start my own project or following examples

Posted 25 May 2011 - 09:35 AM

Hi guys I been keep putting off learning PHP however i was wondering what do you think is the best way to learn.

I got a good project that I can use that will require a user membership access comments forum etc. However would it be easier to following example out of a book and learn the theory with it. Or put myself in the deep end and learn as i go for example. I look at people's example and just modify to fit my needs

Thanks for any advice
Regards Tom

Is This A Good Question/Topic? 0
  • +

Replies To: What the best way to learn start my own project or following examples

#2 creativecoding  Icon User is online

  • Hash != Encryption
  • member icon


Reputation: 922
  • View blog
  • Posts: 3,195
  • Joined: 19-January 10

Re: What the best way to learn start my own project or following examples

Posted 25 May 2011 - 09:57 AM

Experience is the best way of learning. At least for me it is.

Start out small. A forum is way too big of a project to start with. Make something like a guest chat or user system.

In my own opinion, I would start with a file upload. It teaches you the basics of HTML while offering multiple things to do in PHP. Whenever I am bored I find myself constantly working on my own file upload.
Was This Post Helpful? 0
  • +
  • -

#3 eZACKe  Icon User is offline

  • Garbage Collector

Reputation: 120
  • View blog
  • Posts: 1,278
  • Joined: 01-June 09

Re: What the best way to learn start my own project or following examples

Posted 25 May 2011 - 10:45 AM

I often find the best way to learn is to look at and understand examples, and then build upon them.

I went through a PHP/Javascript/MySQL book that I bought, and at the end they had a full implementation of a mini-social networking site. I am now trying to build upon that and add a lot of my own features.

Whatever you do, don't be overly ambitious. You have to start small on things that you will be able to do, or else you'll just get discouraged.

EDIT: In case you're wondering, this is the book. It's a very beginner level book, but I learned a lot from it. :bigsmile:

This post has been edited by eZACKe: 25 May 2011 - 10:47 AM

Was This Post Helpful? 0
  • +
  • -

#4 codeprada  Icon User is offline

  • Changed Man With Different Priorities
  • member icon

Reputation: 943
  • View blog
  • Posts: 2,353
  • Joined: 15-February 11

Re: What the best way to learn start my own project or following examples

Posted 25 May 2011 - 10:55 AM

When learning a new language it's best to read a book.

Why?
A (good) book is structured in a way so that you aren't introduced to advanced topics before knowing the basics or prerequisites.

Jumping into online tutorials and advanced projects without knowing the basics is only going to make your head hurt and become frustrating. Take my advise and take the time to read a book.
Was This Post Helpful? 1
  • +
  • -

#5 calebjonasson  Icon User is offline

  • $bert = new DragonUnicorn(); $bert->rawr();
  • member icon

Reputation: 207
  • View blog
  • Posts: 988
  • Joined: 28-February 09

Re: What the best way to learn start my own project or following examples

Posted 26 May 2011 - 09:21 AM

I think that a good book such as codeprada mentioned is a good idea but then again I learned by doing things the wrong way and having to fix them later.

If you are interested in learning php through small projects I would start with something that simply stores information and retrieves the information from a mysql database. This will allow you to get the hang of using variables, arrays, using functions etc. Once you have a good grasp on this you may want to work on modifying strings and learning regular expressions.
Was This Post Helpful? 0
  • +
  • -

#6 clarkeash  Icon User is offline

  • D.I.C Head

Reputation: 3
  • View blog
  • Posts: 56
  • Joined: 04-February 11

Re: What the best way to learn start my own project or following examples

Posted 30 May 2011 - 04:48 AM

I am fairly new to php (6 months of experience - still very basic knowledge) , so i know how scary it all seems at first.
In my personal experience i started by looking at a few tutorials and examples.
I started with http://devzone.zend.com/article/627
and using w3schools

After a few examples I started making a few simple scripts
eg1 - I had a page with a header and footer and which was separated into 3 pages (main.php, header.php, footer.php) and then i included the header and footer into main.php. This essentially allows to use one header page on several pages so you do not need to edit lots of pages.
eg2 - I had a form that asked for your name when you pressed submit it would say "hello your name"

At the end of the day you need to do things however you learn best.

Best of luck

Clarkeash
Was This Post Helpful? 0
  • +
  • -

#7 Dormilich  Icon User is online

  • 痛覚残留
  • member icon

Reputation: 3392
  • View blog
  • Posts: 9,586
  • Joined: 08-June 10

Re: What the best way to learn start my own project or following examples

Posted 30 May 2011 - 05:45 AM

View Postclarkeash, on 30 May 2011 - 01:48 PM, said:

In my personal experience i started by looking at a few tutorials and examples.
I started with http://devzone.zend.com/article/627
and using w3schools

IMHO, donít rely too much on w3schools. most of the stuff there is better explained in the Manual.
Was This Post Helpful? 0
  • +
  • -

#8 clarkeash  Icon User is offline

  • D.I.C Head

Reputation: 3
  • View blog
  • Posts: 56
  • Joined: 04-February 11

Re: What the best way to learn start my own project or following examples

Posted 30 May 2011 - 06:00 AM

View PostDormilich, on 30 May 2011 - 05:45 AM, said:

View Postclarkeash, on 30 May 2011 - 01:48 PM, said:

In my personal experience i started by looking at a few tutorials and examples.
I started with http://devzone.zend.com/article/627
and using w3schools

IMHO, donít rely too much on w3schools. most of the stuff there is better explained in the Manual.

Thats true, i just found w3schools good for when i very first started (for very basic stuff) as php.net can seem complicated at first.
Was This Post Helpful? 0
  • +
  • -

#9 Hiram  Icon User is offline

  • D.I.C Head

Reputation: 69
  • View blog
  • Posts: 203
  • Joined: 02-June 09

Re: What the best way to learn start my own project or following examples

Posted 30 May 2011 - 07:27 AM

I'd definitely recommend starting small, and learning everything bit by bit. Learn basic output, math functions, etc, then progress to form handling, make a calculator, etc. Eventually, you can move onto the bigger things.

I remember trying to learn Game Programming back when I was in the very early stages of programming. It did nothing for me, and even now that I can actually do game programming, I can't remember anything from back then, except that the whole ordeal made me feel stupid and completely out of my depth. Trying to tackle enormous things you don't understand usually doesn't turn out well :P

For a "long term" project after you've learnt everything, I'd consider developing a simple blog before moving on to your forum. They have simple functionality, and let you play around with lots of different things you'll have learnt.
Was This Post Helpful? 0
  • +
  • -

#10 CTphpnwb  Icon User is offline

  • D.I.C Lover
  • member icon

Reputation: 2834
  • View blog
  • Posts: 9,740
  • Joined: 08-August 08

Re: What the best way to learn start my own project or following examples

Posted 30 May 2011 - 07:30 AM

You need to both read and work on your own projects, but always worry more about your structure than about whether or not the code works. Structured code is easy to read, and the easier it is to read the easier it is to get it working. Working code that has no structure is very hard to modify, so you might have code that works at what it does so far, but you find it impossible to finish.

Some things to keep in mind when starting out in PHP:
  • Functions are your friends. Use them to break large problems into smaller, more manageable ones.
  • Loops are also your friends. Any time you have repetitive code you can simplify it with a loop.
  • HTML is not PHP and PHP is not HTML. They're processed on different computers and at different times. Learn the difference and keep the two apart.
  • $_POST and $_GET are variables like any other. There's never a good reason to do this: $username = $_POST['username'];
  • If you're not using prepared statements (ie PDO or MySQLi) then never put user supplied data directly into a query.

This post has been edited by CTphpnwb: 30 May 2011 - 07:42 AM

Was This Post Helpful? 1
  • +
  • -

#11 eZACKe  Icon User is offline

  • Garbage Collector

Reputation: 120
  • View blog
  • Posts: 1,278
  • Joined: 01-June 09

Re: What the best way to learn start my own project or following examples

Posted 31 May 2011 - 08:07 PM

View PostCTphpnwb, on 30 May 2011 - 12:30 PM, said:

Some things to keep in mind when starting out in PHP:
  • $_POST and $_GET are variables like any other. There's never a good reason to do this: $username = $_POST['username'];


Hmm, I'm actually guilty of this very often.

So for example, I should do something like this:
if($var == $_POST['username'])
{
   // do something
}


Instead of something like this?:
$username = $_POST['username'];
if($var == $username)
{
   // do something
}



I never even considered doing the first option...I don't know why.

Besides being less code and 1 less variable declaration, is there really a big advantage int he 1st approach?

This post has been edited by eZACKe: 31 May 2011 - 08:08 PM

Was This Post Helpful? 0
  • +
  • -

#12 NotarySojac  Icon User is offline

  • D.I.C Regular
  • member icon

Reputation: 53
  • View blog
  • Posts: 428
  • Joined: 30-September 10

Re: What the best way to learn start my own project or following examples

Posted 01 June 2011 - 07:53 AM

I just wrote a tutorial to teach people about netbeans 7.0 and PHP programming on it. I think it's awesome, but I talk fast so you'll prolly have to pause and rewind on some of the steps.

How to setup a PHP programming environment with netbeans 7.0

It's fresh, very little of it is out of date atm!
Was This Post Helpful? 0
  • +
  • -

#13 CTphpnwb  Icon User is offline

  • D.I.C Lover
  • member icon

Reputation: 2834
  • View blog
  • Posts: 9,740
  • Joined: 08-August 08

Re: What the best way to learn start my own project or following examples

Posted 01 June 2011 - 10:33 AM

View PosteZACKe, on 31 May 2011 - 11:07 PM, said:

I never even considered doing the first option...I don't know why.

Besides being less code and 1 less variable declaration, is there really a big advantage int he 1st approach?

Well, less code and 1 less variable is a good thing, right? ;)

There's also the advantage of knowing that you're dealing with user supplied and therefore not-to-be-trusted data later on in your code. If you were going to put $_POST['username'] into this query:
$query = "SELECT * FROM sometable WHERE theusername='".$_POST['username']."'";

you'd know by looking at it that you've made a serious security mistake. If you had this:
$query = "SELECT * FROM sometable WHERE theusername='".$username."'";

you might forget that $username came from the user and needs to be scrubbed before being used in a query. We see this problem here all the time.
Was This Post Helpful? 1
  • +
  • -

#14 eZACKe  Icon User is offline

  • Garbage Collector

Reputation: 120
  • View blog
  • Posts: 1,278
  • Joined: 01-June 09

Re: What the best way to learn start my own project or following examples

Posted 01 June 2011 - 11:48 AM

Very good point.

Of course, if you use PDO the security mistake could be removed all together. :bigsmile:

This post has been edited by eZACKe: 01 June 2011 - 11:50 AM

Was This Post Helpful? 0
  • +
  • -

Page 1 of 1