Grow your CSS skills. Land your dream job.

Beginning to learn PHP – Any tips?

  • # April 10, 2013 at 7:10 am

    After my final GCSE exams in 5 weeks I’ll be continuing to learn PHP, really excited to get stuck into it again!
    Any tips?

    # April 10, 2013 at 7:21 am

    http://www.php.net/manual/en/langref.php, I learned PHP by following their manual, and practicing.

    # April 10, 2013 at 10:08 am

    Thanks!
    How long did it take you?

    # April 10, 2013 at 10:32 am

    It’s something that will vary from person to person in terms of how long it will take you to learn php. A majority of learning php is trial and error, and occasionally maybe a little help along the way. It’s not something you will be able to learn over night. One thing that you want to make sure of is that you pay attention to how you program. Take the time to learn about common mistakes made in php programming that leave your website/ application vulnerable to security problems.

    # April 10, 2013 at 10:32 am

    If you understand the basics of how the language works – how to use functions, how stuff is output – then the rest of it is just memorizing what commands to use for what results.

    Couple things that lots of people get hung up on:

    … PHP runs **first**, on *the server*.

    HTML/JavaScript run **after**, on the user’s *browser*.

    … once you use PHP, *everything* is PHP. Even plain HTML (outside the `< ?php ?>` tags) is PHP output.

    (because of that, I always strive to put all PHP *first* in my scripts, and all output *last* – there are many problems (with sessions, cookies, nice, clean error handling, etc.) you can avoid that way!)

    … `die()` **must die**

    (many tutorials use `die()` for giving error messages – *don’t!*)

    … **never trust user input**. `$_GET`, `$_POST`, `$_COOKIE` – any info you get from your users must be validated (i.e., to make sure it *is* what you *expect*) before use. Sticking it in MySQL queries, emails, HTML output, or almost *any* use in your script can cause serious problems, even if the user is not being intentionally “evil.”

    (speaking of MySQL, many tutorials use the `mysql_*()` functions – **they are now deprecated and should not be used**. Learn to use the [mysql**i** extension](http://php.net/mysqli) or [PDO](http://php.net/PDO) instead!)

    Good luck! Ask if you have any questions!

    -Adrian

    # April 10, 2013 at 10:46 am

    Thanks everyone, It’s something I’ve looked into for a while now and will soon be committing all of my time away from school too, I’m really excited to begin learning some more!

    Is it best to learn MySQL after becoming confident with PHP or at some point during learning?

    # April 10, 2013 at 12:02 pm

    > Thanks! How long did it take you?

    I’m still learning :P

    You can learn MySQL parallel to PHP, once you start using PDO (or mysqli) you’ll need it.

    If you want to be serious with PHP it might be useful to learn the concepts of Object Oriented Programming, and learn a MVC framework (using a good framework will improve your OOP skills if nothing else). But start with basic PHP first.

    # April 10, 2013 at 5:34 pm

    Keep in mind that MySQL is its own language; too many people think of it as a “subset” of PHP, and that leads to problems too

    : )

    # April 11, 2013 at 6:43 am

    Thanks everyone, I’ll keep you all posted!

Viewing 9 posts - 1 through 9 (of 9 total)

You must be logged in to reply to this topic.

*May or may not contain any actual "CSS" or "Tricks".