Misc. PHP

Discussion in 'Introductions' started by sudowin, Oct 24, 2011.

Thread Status:
Not open for further replies.
  1. #1
    Hello everybody,

    I'm new here. Stopping by to say hello. I'll be posting mainly about PHP in these here forums because I'm currently learning it. Since I live in LA I figure it will sound suave if I'm able to say I make cash on the side writing scripts. :cool:

    I'm mainly interested in writing spiders so I'll be asking about that kind of thing. I use LAMP on Ubuntu so I may have questions about this setup as well. If there's anybody out there who hasn't already been annoyed by the plethora of newbs asking about where to get started, I'd certainly appreciate a few pointers. If not, so be it. I'll ask specific questions later.

    :~$ sudo win
     
    sudowin, Oct 24, 2011 IP
  2. sudowin

    sudowin Peon

    Messages:
    5
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #2
    Wow, my bad. I didn't see the introductions forum. Mods, feel free to move this post.
     
    sudowin, Oct 24, 2011 IP
  3. Rukbat

    Rukbat Well-Known Member

    Messages:
    2,908
    Likes Received:
    37
    Best Answers:
    51
    Trophy Points:
    125
    #3
    Where to get started programming. Hmmm.

    "Algorithms + Data Structures = Programs" by Wirth. There are always a few copies available on Amazon for a few dollars (like $5 or less).

    Learning a language before you learn programming is like like flying without a plane. It seldom actually works, unless you just want to fool around with simple scripts. (And a spider is anything but simple.)
     
    Rukbat, Oct 25, 2011 IP
  4. sudowin

    sudowin Peon

    Messages:
    5
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #4
    OOOOH! Well that explains a few things... I've been hitting the PHP books really hard for about two weeks and I've hit a roadblock. I know the basics but I don't know where to go from there.

    I should learn programming before learning the language you say. I shall look into this and report back tomorrow!

    Thanks Rukbat!
     
    sudowin, Oct 25, 2011 IP
  5. Rukbat

    Rukbat Well-Known Member

    Messages:
    2,908
    Likes Received:
    37
    Best Answers:
    51
    Trophy Points:
    125
    #5
    To me, it looks as if PHP was designed to be a language you don't have to learn. It's plain and simple, not obfuscated in any way, no tricks. I don't think anyone who's been programming for a while, in any language, would have a problem learning it by just using the chm file or the online manual.

    The problem, and you fell into the trap just like so many others, is thinking that knowing the syntax is knowing how to use it. I speak English. Shakespeare spoke English, using pretty much the same syntax. The difference is that he knew how to use it. My "deathless prose" needs only one thing - to die before anyone sees how bad it is. Same thing with programming. A good programmer can pick up a language and write a good program in it, but

    if($boolean_value == true)

    is newbie nonsense in any programming language. (It's called a pleonasm.) High level scripting languages make it too easy for people to convince themselves that they know how to write programs, then get stuck on the most basic things. (Those of us who had to start thinking in assembly, or even machine code [try manipulating a program written in split octal without understanding how it works], learned differently from the beginning.)

    Once you learn programming, you'll see that, unless you're trying to write something the size of a complete forum, you don't think about PHP, you think about the problem you're trying to solve, and how to solve it programmatically. Translating the solution into PHP just happens, because when you're working in PHP you're thinking in PHP.
     
    Rukbat, Oct 25, 2011 IP
  6. sudowin

    sudowin Peon

    Messages:
    5
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #6
    Well, I got a hold of "Algorithms and Data Structures" by Mr. Wirth. Apparently it's the updated edition from 1985.

    Since this is my first programming language, (I don't count HTML and CSS as programming languages) I think I'm going to learn a new piece of syntax every day from "PHP 5 Recipes" published by Apress, while reading about the actual process of programming from the Wirth book.

    Thanks a lot for the suggestions Rukbat!
     
    sudowin, Oct 26, 2011 IP
  7. sudowin

    sudowin Peon

    Messages:
    5
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #7
    I'm using this book to learn syntax and I arrived at the following example about using classes and objects:

    It is supposed to return: "Tweety is a canary."
    What it actually returns is: "is a ."
    Is this my fault or the book's fault?
    <?php
      
     class Bird {
         function _construct($name, $breed) {
       $this->name = $name;
       $this->breed = $breed;
         }
     }
     
     $tweety = new Bird('Tweety', 'canary');
     
     printf("<p>%s is a %s.</p>\n", $tweety->name, $tweety->breed);
    ?>
    
    PHP:
     
    sudowin, Oct 26, 2011 IP
  8. sarahk

    sarahk iTamer Staff

    Messages:
    28,818
    Likes Received:
    4,536
    Best Answers:
    123
    Trophy Points:
    665
    #8
    Check the use of _construct

    this works (old school class definition)
    <?php   
    class Bird {
         var $name;
         var $breed;
    
        function Bird($name, $breed) {
             $this->name = $name;
             $this->breed = $breed;
         }
     }  
    
    $tweety = new Bird('Tweety', 'canary'); 
    //var_dump($tweety); 
    printf("<p>%s is a %s.</p>\n", $tweety->name, $tweety->breed);
    ?>
    PHP:
     
    sarahk, Oct 26, 2011 IP
  9. sudowin

    sudowin Peon

    Messages:
    5
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #9
    Thanks saranhk! That works.
     
    sudowin, Oct 27, 2011 IP
Thread Status:
Not open for further replies.