I opened the book "Sams teach yourself PHP in 24 hours" and noticed a huge typo 😉

From the book:

<?php
function addnums($firstnum , $secondnum )
    {
    $result = $firstnum + $secondnum;
    return $result;11:
    }
print addnums(3,5);
//will print "8"
?>

What the fuck is this "11:" doing there?

    On that typo... it shouldn't matter since the error follow 'return;' and anything that follows 'return;' from a function is ignored.

    The bigger problem that I see is the complete uselessness of the function itself. Simply adding two numbers does NOT require a function call:

    $thisnum = 7;
    $thatnum = 12;

    print($thisnum + $thatnum);

    Screw SAMS and their sorry-ass books which, IMHO, deliver nothing but page after page of trivial, useless, non-real-world coding examples. I've spent considerably more than 24 hours on their "Teach Yerself C in 24 Hours", and I'll be damned if I'm a better C programmer because of it.

    Just my too sense...

    Have a nice day!

      I agree that SAMS books are not up to the level of something I wish to read. And the thing about the return value, is correct. It will still work regardless of what is after it.

        Oh yeh I bought SAMS PHP and MySQL Web developement... pretty good book thus far.. however they reference a place to get a script from and that particular url redirects to a porn site..LOLOLOLOL

          lol i think it's time you graduate to the O'Reilly books, they rock 🙂

            zleviticus: was that a free porn site? If so, do share the url! LOL

              IMHO, Sams hires people like me to write the computer language books, and I suck at computer languages! 🙂

              I enjoy the O'Reilly books. They speak my language, pardon the pun.

                Originally posted by wscreate
                IMHO, Sams hires people like me to write the computer language books, and I suck at computer languages! 🙂

                I enjoy the O'Reilly books. They speak my language, pardon the pun.

                Plus the people who write them are among the leaders in the field they're writing about - not hired from Rent-A-Hack. Their Programming PHP and PHP Pocket Reference are (co)authored by Rasmus Lerdorf, the original inventor.

                Well, that's new - when did heyes-computing.net turn into a porn site? Does Richard Heyes know?

                  WeedPack you might be partly wrong on that one.....
                  Jesse Liberty wrote Sams Teach Yourself C++ in 21 Days
                  he ALSO wrote Programming C# (an O'Reilly book)

                  why i bought a .NET book in the first place i have no clue, sorry for my sins 🙁

                    Originally posted by ShawnD
                    .....
                    Jesse Liberty wrote Sams Teach Yourself C++ in 21 Days
                    he ALSO wrote Programming C# (an O'Reilly book)

                    Well, I don't know Jesse Liberty from a bar of soap, so I don't know what he has to do with either C++ or C#, but I take the correction.

                    Among the people who write the books O'Reilly publishes are people who are the leaders in the field they write about (I reverse the containment).

                    Either way, O'Reilly is a geek's publisher, interested in publishing solid and comprehensive textbooks, rather than shallow tutorials that give wannabes just enough to think they're getting a good deal when they buy them.

                    But hey, I bought the Perl CD Bookshelf. Now that was a good deal.

                      WROX Publishing all the way 😃

                        i only started learning stuff like 2 months ago lol 🙂
                        my buddy started to use Linux before me so he bought a bunch of Linux books including' Linux For Dummies', a book simply named 'LINUX' and Running Linux (O'Reilly book). of those books, the O'Reilly one was the best and i wanted to learn C# so i bought the C# book O'Reilly put out. although i couldn't get that stupid ass .NET compiler crap to work, i thought the book was nicely written. next time i went out with my friend to Chapter (huge book store) and i bought Programming PHP by Rasmus Lerdord and Kevin Tatroe (O'Reilly again) and i thought it was pretty damn good, i'm only up to function so far 😉. next books were Linux In A Nutshell and Understanding The Linux Kernel. they are all fantastic books.

                        i'm already eyeing that book "Practical C Programming", there's a higher demand for C programmers so i better learn it 🙂 PHP is just a hobby i'm not really good at 🙂

                          Originally posted by ShawnD
                          i'm already eyeing that book "Practical C Programming", there's a higher demand for C programmers so i better learn it 🙂 PHP is just a hobby i'm not really good at 🙂

                          I hear you.. but you can make some good money off of PHP freelance. But if anything you should learn XML & XSL... everybody for some reason wants that 🙁

                            i want to work for Linux 🙂

                            that way i can understand how to get my damn computer to work! 🙂

                            btw does anybody know a good book to learn C or C++ for LINUX and NOT Windows?
                            i might end up programming for Windows (joining the dark side) but hopefully i'll end up with Linux 🙂
                            Red Hat Linux has a big programming office in Calgary, Alberta, Canada. i live in Edmonton which is only 3 hours away from Calgary....it would be an easy move and the pay is good, there's few who apply because there are not really that many people who can program for Linux 🙂

                              Heehee "C for Linux" - never catch on 🙂

                              Mainly because C was originally designed for Unix-type systems (and indeed, was originally designed to write Unix-type systems).

                              Any decent C reference should provide all the neededs (Windows C is just C with a load of Windows-specific stuff piled on top - ignore windows.h and you'll be fine! 🙂). A lot of Windows software floating around is just C-written-on-Linux that's been ported to run on Windows (PHP is an example).

                              But in the end programming for Linux is best learned by actually programming Linux. If it's not on your machine now you can install it as a separate partition. Red Hat may be a good choice for you. You've seen what their product comes with; it includes a C/C++ compiler. Manuals should be there, but if not http://www.gnu.org/ have plenty (e.g. http://www.gnu.org/manual/glibc-2.2.5/libc.html for their C library, which starts "This manual is written with the assumption that you are at least somewhat familiar with the C programming language and basic programming concepts.").

                              "We don't need books - we've got man pages. You can't grep a dead tree."

                                I got to about 16 errors by 20 pages through that book.

                                Its not that bad a book, in terms of content and all, but it really should have been proof read by a programmer.

                                  yeah lol

                                  by C for Linux i mean something that explains all the calls and stuff like that. when you look at ICQ in your system tray, do you ever wonder "how did they program it to go there?" and things like that? there is a system tray for Linux too but how hard do you think it would be to actually find a referance that explains how?

                                    haha... this is great stuff. damn sams looks like u'll be losing business now.

                                    go with O'REILLY