Winners Announced: Free Copies of “Pro PHP and jQuery”

Winners Announced: Free Copies of “Pro PHP and jQuery”

Jason Lengstorf was nice enough to offer our community a handful of copies of his latest awesome book, Pro PHP and jQuery. Be sure to read his latest Nettuts+ tutorial, “Object-Oriented PHP for Beginners,” based on his book.


Winners Announced:

Congratulations to the following winners, who were randomly selected:

  • Jonathan Stuckey
  • Rick Blalock
  • Matt Vickers

Each of you will be contacted shortly about arranging your free copy. Thanks again to everyone who entered!

“This book is for intermediate programmers interested in building Ajax web applications using jQuery and PHP. Along with teaching some advanced PHP techniques, it will teach you how to take your dynamic applications to the next level by adding a JavaScript layer with jQuery.”

To enter for a chance to win a hardcopy version of the book, leave a comment with a PHP tip. It can be as simple or as long as you like. Just as long as it was something that helped you to learn PHP, that will automatically enter you! On Monday morning, we’ll choose the winners!


You can also purchase “Pro PHP and jQuery” here.

Note: Want to add some source code? Type <pre><code> before it and </code></pre> after it. Find out more
  • Gaston

    I would recommend Jason’s other book PHP for Absolute Beginners (http://www.amazon.com/PHP-Absolute-Beginners-Jason-Lengstorf/dp/1430224738). It really helped me when I was getting started.

  • andrei

    Arrays have been problematic for me so smth you should know

  • Michael

    http://net.tutsplus.com/category/tutorials/php/ Is the way to go for any PHP coder.

  • chris

    that’s easy:

    One of the first things that I loved about php is abstraction of my code. At it’s most simplistic form, you can separate your code into separate files so that they can be reused throughout your website.

    For instance, if you want to save time coding your header, just copy all your header code into a file called “header.php”

    Later, in your various documents, when you want to use your header, you can just call the file as so:

    //Header

    This topic has been discussed ad nauseam but is still a fundamentally useful tool in your PHPtool belt.

    • chris

      haha, my header code was this:

      include(“header.php”);

      I wasn’t aware of what can or can’t work on nettuts :)

  • matteo

    Use a framework like CakePHP, Zend, Symfony or CodeIgniter! Less coding and less debugging.

  • Raanan Avidor

    For debugging add
    error_reporting(E_ALL);
    at the beginning of your script.

  • http://robopixel.com FelixHCat

    Hmm a tip… Start with an MVC framework early — Codeigniter is easy to pick up and will change your life — Frameworks separate different parts of your code, abstract common functions and create clean, maintainable, Object Oriented code.

    You’ll be coding like a pro in no time ;)

    Also, PHP has a function for EVERYTHING… it’s my PHP motto, “There’s a function for that!”

    Happy Coding :)

  • mike

    Find a problem or need that you have and create a solution from scratch. Be persistent and don’t give up.

  • Thall

    if(i % 2 == 0) //Check if i is even

  • http://chriswastell.bluehorizonhosting.com Chris Wastell

    Never neglect constructors. Learning another OOH language e.g. Java will teach the importance of these in OOH in PHP and teach your not to misuse them and avoid displaying data with them

  • http://www.theheartsmasher.com TheHeartSmasher

    Some developers use the smarty template engine for their php templating but have always wondered how they could go about have one php page but multiple smarty templates used for that page depending on what is being requested in the url.
    Code example
    —-
    index.php in your public directory
    —-
    function cleanaction($page){
    $action = $_GET['page'];
    /**
    * Code to clean input, verify input from the url request
    * Example: http://localhost/index.php?page=news shows the information in news.tpl
    * Non existing page http://localhost/index.php?page=noodles will show what is in the index.tpl.
    **/
    return $mycleanedaction;
    }

    switch(cleanaction($_GET['$page'])){
    case news:
    $smarty->assign(‘pagetitle’,'News’);
    $smarty->display(‘news.tpl’);
    break;
    case aboutus:
    $smarty->assign(‘pagetitle’,'About Us’);
    $smarty->display(‘aboutus.tpl’);
    break;
    case contactus:
    $smarty->assign(‘pagetitle’,'Contact Us’);
    $smarty->display(‘contactus.tpl’);
    break;
    default:
    $smarty->assign(‘pagetitle’,'Welcome to website name’);
    $smarty->display(‘index.tpl’);

    }
    —-

    This should help cut down on your code and keep it a little more organized so you don’t have to use multiple if statements just to check what is being requested for the page. In your cleaning code you should remove everything except for alphanumeric characters, does not go over a maximum length and anything else you feel will keep things clean.

  • Jake

    If you live to optimize your code to the fullest, always use “echo” instead of “print” in your PHP code. To the untrained eye, they essential accomplish the same thing. However, “echo” is almost 50% faster than “print”. We may be talking nano-seconds of difference, but in many cases for a large page with many loops, it can make a significant difference.

  • http://kodegeek.wordpress.com Musa

    Use Ctype functions(Available in php 4, php 5) to input validation, it will save your time – see details here – http://www.php.net/manual/en/ref.ctype.php

  • Muhammad Aimash

    Use sprintf function to add variable in mySQL query its easy and safe :
    $query = sprintf(“insert into posts
    set title = ‘%s’,
    body = ‘%s’,
    created_at = NOW(),
    user_id = ‘%s’
    “,
    mysql_real_escape_string($params['title']),
    mysql_real_escape_string($params['body']),
    mysql_real_escape_string($params['user_id']));

    $result = mysql_query($query);

  • http://sportsenthusiasm.com Tyler

    May be obvious to some, but CakePHP is a fantastic web framework for getting a PHP site up and running quickly. Works great for blogs and community-oriented sites.

    Link: http://cakephp.org/

  • http://www.ophini.com Eugene Akiwumi

    I would love to get a free copy of this book, as I am just starting out in web design.

  • http://www.soleestivo.com Dylan McDonald

    In PHP you may use short or long opening tags for php. <? being the short version, and <?php being the long version. But be wary when using short tags, as some servers may not be configured to recognize short tags. If you are running your own server, be sure to check your php.ini file and set "short_opentag=On"

  • http://www.jblfmu.edu.ph Bong

    Hi, I hope i can win a copy of this book. Thank you and God bless

  • http://www.in-the-attic.co.uk Garry Welding

    strlen is slow, instead of:

    if(strlen($str) == 32) …

    instead try:

    if(isset($str{31}) && !isset($str{32})…

    isset is a language construct in php and therefore is much much quicker. this can be modified for any strlen condition really.

    if(strlen($str) < 33)…

    can be changed to:

    if(!isset($str{32})…

  • http://datasplash.co.uk Darren Lunn

    I’m in that php learning journey right now, I know other platforms quite well, and my advice is plain and simple:

    • Buy some books (Apress are particularly good)
    • Listen to and read net.tutsplus (Jeff is a very good tutor, and others)
    • Go somewhere quiet and begin, without interuptions.

    That’s working for me at the moment. Along with the tut series about CodeIgniter which I’m using as the prototype project. The combination is very powerful as a learning process.

  • Mladen

    When using PHP within HTML you can close the PHP tag when you want to output HTML. This makes for speedier processing of your PHP scripts, because you don’t have unnecessary print, echo and other commands. Example:

    Hello World!

    Hello Mars! You are the planet.

  • http://www.craigcoles.co.uk Craig Coles

    If you ever have a problem, echo the outputs in mutiple places to establish where things are going wrong.

  • http://danielmorgan.co.uk/ Daniel Morgan

    When working with a mysql database, use a pre made database class. I got a great one from http://www.phpclasses.org/. A good one will report errors in a much more meaningful way, and makes writing queries quicker.

  • http://www.mohammadatif.com Mohammad Atif

    avoid using short hand operators rather use

  • Rob Yallop

    I had some functions calculating dates by adding multiples of 86,400 seconds to the start date. However, this caused problems in weeks where there were daylight savings changes (i.e. switching the time in Spring and Autumn).

    One solution is to make sure your start time is not around midnight (i.e. the date with no hours, minutes and seconds). However, I found the strtotime function to be easier to work with. I’m guessing it’s a bit slower, but I was happy with the results.

    $date = date(“Y-m-d”);// current date

    $date = strtotime(date(“Y-m-d”, strtotime($date)) . ” +1 day”);

  • Estere Priedīte

    Use ip2long() and long2ip() to store IP addresses as integers in database instead of strings.

  • Nedyalko Stefanov

    FirePHP is a great tool to debug your code.. great also for the sql optimization.
    And always plan a good structure of your system, before you start… organize everything in folders and avoid long lines and big files with messy code.

  • Wojtek

    When testing values with boolean AND (&&) operator, values are tested from left to right and after first false condition no more testing is done. So if You write:
    if ( isset ( $foo ) && $foo = ‘value’ )
    {
    do_something;
    }
    You can be sure you won’t get unknown variable waarning.

  • crk

    try to develope Your own sandbox, with most common functions, helpers, css templates.. etc. either if it’s MVC framework or clear php+mysql.. sandbox will speed things up..

  • http://www.crunchypickle.com Kevin Joseph Remisoski

    Instead of using © 2010 in your footers, if you’re already dealing with a PHP file just use:

    © This makes a lot more sense since you’ll never have to change the year.

  • http://www.crunchypickle.com Kevin Joseph Remisoski

    Instead of using &copy; 2010 in your footers in PHP, try using &copy; <?php echo date(‘Y’); ?> This makes a lot more sense since you’ll never have to go back and change the date.

  • creatoro

    Use meaningful names for variables, functions, classes, etc. and document every little step by adding comments to your code. When you look at it later it will be much-much easier to find what you are looking for if you stick to this rule.

  • http://www.otoolewebdesign.com Shaun

    I started learning PHP by hacking around with WordPress. Once I was hooked I came to Nettuts to really learn the language!

    http://net.tutsplus.com/tutorials/php/learn-php-from-scratch-a-training-regimen/

    Does kissing butt give me a better chance at winning?

  • http://www.trinitybyte.com TrinityByte

    I would so love a copy, it would help in all of my studies

  • http://www.purplecoffee.co.uk Gareth Evans

    echo ”, var_dump( mixed $expression ), ”;

    Especially useful when checking arrays!

  • http://ilamaan.com ilamaan

    define() function is used to define constants and u can use this function by define(‘the constant name’,'anything u want to be seen after call the constant name defined before’);
    you can call using echo like this: echo theconstantname; no need of inverted comas.

  • http://www.tlswebsolutions.com/ Tim Selaty

    When printing a string to the browser you can concatenate variables when using double quotes two ways.

    echo “My string ” . $variable . ” has a variable.”;

    echo “My string {$variable} has a variable.”;

    Logically and programmatically speaking, using single quotes with the ‘ . ‘ method is the fastest.

  • http://meaddesign.net Bill Mead

    Personally I think learning PHP is one of the best ways to get into programming. I have tried learning lots of various programming languages, but PHP is the one that really stuck for me. From there, learning javascript and other languages was easier.

  • Стоян Киров
  • Bruno

    Here are some php optimization tricks. Very useful in large applications. Enjoy it!

    http://ilia.ws/archives/12-PHP-Optimization-Tricks.html

  • knico

    Read these 12 pages of awesome tips!

  • http://themprint.cleanfolio.com Amon

    If you want to see if your code can access a particular function in the version of php being used you can use something like this:

  • http://www.shopztop.com John
  • http://www.tonyvirelli.com Tony Virelli

    PHP in easy steps was a great learning tool when I first started. Got it at Barns and Nobles for like $10.00!

  • http://felixb.se Felix

    I would really like to win this book! :)

  • Ken

    Quick tip: be careful with boolean values in PHP. For example, 0 == “str” evaluates to true. Use === instead to check type.

  • http://adi.nuta.me Adi

    I started looking at other people’s work and then modify it and see what happens.

  • http://www.art-forums.net Rory

    for($i = 0; $i < 20; $i++){
    // Code to run while $i is less than 20.
    }

    For loops can be used to cycle through anything from a bunch of variables, to arrays. They're more convenient than while loops, because we set the variable, condition and control the number of repeats all from within the opening statement.

  • http://www.marcooliveira.com Marco Oliveira

    Nowadays websites are more and more international, and multi language may arise on your projects. To prevent many sorts of problems, whenever handling strings, don’t forget to use the multi-byte functions provided by PHP, use the UTF8 internal encoding, and use the utf8 encode and decode functions whenever strings need to be received/sent from sources that provide/are expecting ISO-8859-1 encoding. Finally, if you ever need to transport UTF8 strings into a database, don’t forget to run “SET NAMES utf8″ after every connection (on a side note, some abstraction layers, like PDO, already provide mechanisms to run this command automatically).

    Hope you find this useful.

  • http://codemonkeys.biz Kris

    Var_dump accepts multiple variables as parameters. That is very handy for debugging and allows you to do things like: echo(var_dump($var1, $array1, $var2)).