Diving into PHP: Day 3

I’ve decided that this series won’t be 100% “by the book”. Though you MUST learn the fundamentals, I think it might be nice to learn some more “fun” things right now. Otherwise, you’ll go mad trying to memorize the if, for, foreach, while, and switch statements.

We’ll absolutely learn those – but in due time. Today, I’m going to show you how to pass values from page to page by using super-global arrays. I hope you enjoy it!

P.S. Please help one another in the comments section.

Day 3: Passing Values From Page to Page

Download the Source Code



64

Comments
  • wrerm says:

    I love this tutorial…

    I’ve noticed that if you need to use single quotes. Page2 would look like this:
    echo ‘Go to Page 2‘;

  • CgBaran Tuts says:

    Great tutorial thanks

  • Mike says:

    I just wanted to say thanks for creating these videos. I have been working on learning PHP for about a month now and these videos are by far the best training tool I have come by. You have a rare talent not found very often of talking in a way that makes sense. <– haha

    Some people are cut out to be great teachers and I know you are one of those people. Keep up the good work.

  • Ray says:

    Hi, thanks for some great vids.

    I’ve encountered similar issues as Simpson and ScottM: When using the exact same code as Jeff the browser only states: Hello,

    How can i fix this?

    Thanks,

    Ray

  • Ray says:

    Solved it!

    The get string had some capital letters that i had missed, when ik typed the GET statement EXACTLY as in the index.php form it worked like a charm!

    Hope this solves the problems of others too!

  • Bl0ckHead says:

    was curious about how to implement the variable from day2 into day3. where it could use the if else statement and spit out Your name is Jeff, yourName or Your name is not Jeff, yourName

    great job BTW and thank you

    Bl0ckHead

  • Jason says:

    Why does this make a difference:

    echo “Got to page 2“;

    versus

    echo ‘Got to page 2‘;

    With the former everything works correctly and page 2 shows Hello Joe but with the latter it shows Hello $myVariable

    I’m not sure I understand why it works that way. . .

  • mike carey says:

    Jeffrey- these (and your other screencasts) are awesome- well presented and you have a teacher’s gift !

    Is there a way you can link the episodes together- so when you post $5, there is a link on #4 to get you to #5 ? (or is there already there and I am just missing it ?)

    thank you for your wonderful work.

  • Zac says:

    @Jason – Just by quickly reading your comment I’m guessing you didnt concatenate in the second example. When using single quotes you have to do what is called concatenating. If you don’t, php will view $myVariable as what you want the browser to actually display. If you concatenate the variable the php will realize its a variable and replace the variable with its value. Check out day 2, Jeff goes over it better than you will ever have it explained in your life.

  • Joel says:

    I can’t seem to play the video on Day 3. Is there a way to fix this? Thank you.

  • Joel says:

    Nevermind, it works already. Thanks.

  • Towel says:

    For some odd reason, my version is not working. I have gone through and compared my version, which is identical to Jeff’s. I put Jeff’s version on my site (not working on localhost because WAMP wasn’t working, figured since my (mt) website had PHP i would use that) in the same folder, and it worked. My doesn’t though. I checked period for period, semi-colon for semi-colon, all the same.

    If anyone could help that would be amazing.

  • Mars says:

    think you should have noted not to use PRINT instead of ECHO.
    I remember from the first video, you mention print and echo. That there is no real difference…
    Well I used PRINT instead of echo, just to keeps things similar flow.
    It took me 10 min to figure out why “myVariable” was being shown instead of the value given to it in page3.php