Web Analytics Made Easy -
StatCounter need help.. *I'm beginner* - CodingForum

Announcement

Collapse
No announcement yet.

need help.. *I'm beginner*

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • need help.. *I'm beginner*

    Hello,

    I've been trying to learn PHP from a book.. I'm VERY VERY confused on PHP.
    Like What are Arrays? How do you make a script from using php? by connecting from other files?

    I decided that My book is too hard.. I might consider trying to learn from the web..

    This is what I know/learned so far:

    PHP Code:
    <?php

    print "hello";
    print 
    "hello2 xD";

    $number1 "5";
    print (
    $number1)

    ?>
    I'm pretty sure thats all wrong.. I really want to learn PHP but I don't know where to start!!

    If I DID that correctly, please tell what the next thing I should learn (links, etc.)

    If I DIDN'T do that correctly, please correct my errors and tell me what I should learn next.

    Thanks alot.

  • #2
    Questions for you:

    What book are you using?

    Are you using a host that has PHP installed where you can upload PHP files?

    Regarding the code you posted, have you viewed it from your browser? Do you get any errors or warnings when you do? The last print statement has the wrong syntax, but you should figure out what's wrong with it yourself by reading the warnings/errors you get when you view it in a browser.

    Comment


    • #3
      Originally posted by Fumigator View Post
      The last print statement has the wrong syntax
      Not true, that's perfectly acceptable syntax.

      I'm not sure what you're asking here, can you explain a little more? The code looks fine to me.
      -Brando
      Why using tables for eating is stupid!

      Comment


      • #4
        I was under the impression semi-colons are required. Are they optional?

        Comment


        • #5
          Hi, thanks for replys.

          Well if that code I just posted is right, what should I learn next?

          That's all I know in PHP right now.. (Yeah.. I'm nOoOOb)

          Thanks.

          Comment


          • #6
            Originally posted by Fumigator View Post
            I was under the impression semi-colons are required. Are they optional?
            eh, they are required. php gets nasty if a semi-colon is missing. at least it alwyas has for me.

            Anyways, you should probably check out a few of the bagillion php tutorials out there. Here's some good ones:

            http://ca3.php.net/tut.php
            http://www.tizag.com/phpT/
            http://www.w3schools.com/php/default.asp

            Or just google "php tutorial" and pick one.

            Comment


            • #7
              Originally posted by Fumigator View Post
              I was under the impression semi-colons are required. Are they optional?
              This is a very rare exception. The last line doesn't require a semicolon but not adding it can definitely make it harder to add code after the last line as you wouldn't expect it not to be there. It would also be utter laziness not to add one character...
              I'm not sure if this was any help, but I hope it didn't make you stupider.

              Experience is something you get just after you really need it.
              PHP Installation Guide Feedback welcome.

              Comment


              • #8
                the best way to learn php is by giving yourself a simple project that you want to write a script(s) for. something like an address book that you can build a form, insert the form info into a database, retrieve the information from the database, and display your results in a web page. write out your simple tasks on paper first, then start to build your script by checking off each task on your list. if you start off with small steps, you can learn more php functions as you go.

                go along with the samples in your book if there are any. if you decide to start with a simple address book, you can always get help here with any errors or results. thats what makes ths forum good. no one will do the work for you but people are always give you a push inthe right direction.

                good luck and keep the forum informed.

                c.c.

                Comment


                • #9
                  i started with this...
                  http://en.wikibooks.org/wiki/Web_Des...PHP_Challenges
                  hope you manage to do this, if not keep it bookmarked till your a little more congfident

                  Comment


                  • #10
                    err...

                    @ClubCosmic: How do I make a script if I don't know how to make it?

                    So.. should I download a script, look at the codes, and learn?

                    I mean.. I probably don't know the basics..

                    I dont' know what arrays are.. how a script is formed..

                    thanks.

                    Comment


                    • #11
                      Originally posted by Mindelude View Post
                      err...

                      @ClubCosmic: How do I make a script if I don't know how to make it?

                      So.. should I download a script, look at the codes, and learn?

                      I mean.. I probably don't know the basics..

                      I dont' know what arrays are.. how a script is formed..

                      thanks.
                      Check out some of the tutorials, and maybe download some open source software, and take a look, most of it is commented, so you can understand what it means.
                      ttttt
                      http://openoffice.org/- Microsoft Office without the Microsoft.
                      [home page][forum]
                      Versatile, free software

                      Comment


                      • #12
                        Arrays are very useful and probably confusing to a beginner. I second the motion that you need to invent a project and then learn what you need to make it happen.

                        This is how I learned. Motivation and php.net

                        There is no substitute for motivation and dedication to a task. Writing php is writing a php script.

                        PHP Code:
                        $i 1;
                        $j 2;

                        if(
                        $i $j )
                        {
                             echo 
                        'i is greater!';
                        }
                        else
                        {
                             echo 
                        'j is greater!';

                        To give you a quick sample of an if statement. But then you could also say...

                        PHP Code:
                        $i 1;
                        $j 2;

                        echo 
                        $i $j 'i is greater!' 'j is greater!'
                        Learning and becoming confident w/ the syntax, loop constructs and most importantly learning how to research to find answers to your problems (php.net is a great resource for official documentation and user contributions [code snipppets]) are measures of success when learning a new language.

                        Best of luck learning, dont give up. You might also consider finding a local tutoring service or even a distance learning one. It might be all you need to get on the right track and build some confidence.

                        I'm in the process of launching such a site - get a hold of me if you're serious about learning.
                        Active PHP/MySQL application developer available for immediate work.
                        syosoft.com mavieo.com - Remote Web Site Administration Suite - Reseller Ready

                        Comment


                        • #13
                          thanks syosoft!

                          That was good information.'

                          Can you explain what the 'If" is and how to use it?

                          Comment


                          • #14
                            If is an if statement:
                            PHP Code:
                            <?php
                            if (condition is true)
                            {
                            perform}
                            ?>
                            You can also have if else, etc.
                            So:
                            PHP Code:
                            //variables
                            $myage 100000000;
                            $yourage 20000;
                            if (
                            $myage == $yourage)
                            {
                            //if we're the same age, state that
                            echo ('We/'re the same age!');
                            }
                            else
                            {
                            //nested if statement
                            if ($myage > $yourage)
                            {
                            echo ('
                            Howdy youngster');
                            }
                            }
                            else
                            {
                            //if nothing else is true
                            echo ('
                            OAP Alert!!!!');

                            Hope this helps,
                            Last edited by ttttt; Sep 30, 2006, 04:32 PM.
                            ttttt
                            http://openoffice.org/- Microsoft Office without the Microsoft.
                            [home page][forum]
                            Versatile, free software

                            Comment


                            • #15
                              If statements are good for conditional coding. However, people often use them when a switch/case would be more appropriate. They both offer the same basic functionality, however, with an if() statement, you have to code in order of execution where as with a switch statement you can create cases as you see fit and the php interpreter will decide which case is correct for the given option.

                              Consider the following:

                              PHP Code:
                              $j 1;

                              if(
                              $j == 0)
                                   echo 
                              'The value of $j is 0';
                              else if(
                              $j == 1)
                                   echo 
                              'The value of $j is 1';
                              else 
                                   echo 
                              'The value of $j is '.$j
                              The above is a perfectly valid example of an if statement. However, why have php check the first if() when clearly it would be faster if it could just jump to the first else if...this is where switch/case comes in.

                              PHP Code:
                              $j 1;

                              switch(
                              $j)
                              {
                                   case 
                              0:
                                       echo 
                              'The value of $j is 0';
                                   break;
                                   case 
                              1:
                                       echo 
                              'The value of $j is 1';
                                   break;
                                   default:
                                        echo 
                              'The value of $j is '.$j;
                                   break;

                              The basic idea behind a switch/case is that PHP can "jump" right to the most appropriate case without having to do unnecessary evaluations - At least as far as I understand it. They also make coding a lot easier as you are freed from worrying about the order of execution (does this else if need to go before this one?).

                              These are very basic examples and i'm sure it's hard to see how they would be used in real world coding - however, just like all the stuff you learn in school that you thought you'd never use, it prepares you for when you have to make educated decisions based on everything you retained.
                              Active PHP/MySQL application developer available for immediate work.
                              syosoft.com mavieo.com - Remote Web Site Administration Suite - Reseller Ready

                              Comment

                              Working...
                              X