Jump to content

Home

Recommended Posts

You can pass as many variables via GET (in the URL) as you like.

 

it goes like this:

 

In page.php?var1=foo&var2=bar&var3=woogawooga

 

$var1 == "foo"

$var2 == "bar"

$var3 == "woogawooga"

 

The ampersand just marks where one value ends and the next variable name begins. No fancy referencing involved. Beware: GET values do NOT need quotes to indicate strings. Everything in the request is considered a string automatically.

 

Note that if you're going ot pass arrays between pages, you'll have to serialize() them (which converts an array to a text string), then unserialize() (the opposite effect) on the receiving page. For stuff like arrays, objects, image resources, and stuff like that you're way better off using session variables.

 

session_start();

$someobject = new FooBar();

session_register("someobject");

$someobject->var1 = "foo";

 

[ User then clicks to go to the next page]

 

NExt page has:

 

session_start();

 

and we find that $someobject is still available between pages as long as you remember to call session_start() on each page to resume the current session.

 

For easy stuff like $foo = "bar" though, GET is the way to go. Much simpler.

Link to comment
Share on other sites

Originally posted by Moosferatu

I have made one section with sessions, and I'm hoping that I won't have to make anymore.

 

What's wrong with sessions? As long as you remember to use session_start() to resume your session on each page, they're not hard at all.

 

Originally posted by twifkak

Woah. PHP is cool.

 

:)

Link to comment
Share on other sites

Originally posted by tabacco

What's wrong with sessions? As long as you remember to use session_start() to resume your session on each page, they're not hard at all.

 

True...

 

I don't really have any good arguements... I guess I just prefer not using them.

 

I second the motion on PHP's coolness. BTW, does anyone know when PHP 5 is supposed to be done? I know it is being beta tested right now.

Link to comment
Share on other sites

Well, with Beta 1 just out, it's probably going ot be awhile. Since a lot of sites rely heavily on PHP, they need to make dead sure it's stable, secure, and bug-free before they can declare it final. I haven't tried 5.0.0b1 yet, but it looks pretty cool. I'm looking forward to having try/catch available.

Link to comment
Share on other sites

I wouldn't call them a joke, they're actually quite good compared to a lot of Internet-centric languages that aren't called Java or C#. But yeah, some of the things they left out were questionable. PHP5 seems to take care of that.

Link to comment
Share on other sites

Originally posted by RemiO

Not to mention a vastly improved object model. Why PHP4 never included a destructor is beyond me.

 

if you dig objects and want to experience some real OO programming (not retrofitted like php or perl), then be sure to check out ruby:

 

http://www.rubycentral.com/book/

 

moosferatu, if you think you're having fun with php, you would never be able to wipe that smirk off your face once you are spoiled by ruby. it is like going from b&w to color, from crt to lcd. and it's all free, too (open source).

 

-10bt

Link to comment
Share on other sites

It looks pretty interesting. I have just started to get into programming. I have been wanting to for years, but never got around to it. I pretty much have the basics down on PHP, now. I am going to be taking an online class here this school year, learning Java. Since the course is self-paced I should be able to finish it within the first semester and then move on to C++. Why take a class you ask? Because I get credit for it. I wouldn't get any credit if I just learned it on my own. I am, also, about to start in on JavaScript. I have heard some good things about Python and thought that after I finished the above I might look into it, but after reading some of the stuff about Ruby, I might want to look at that instead. Any suggestions?

 

The following is why I am interested in the above mentioned languages.

 

Java - Two reasons. One, and most important, it is currently the language that the AP Computer Science exam is in. I used to be C++, but it has changed. Two, because it seems that it could come in handy in web developement.

 

C++ - I want to learn it because it seems to be required for any type of programming position. Also, if I want to someday get into Double Fine, I'll need to know it. ;)

 

JavaScript - Because with it I can do some cool stuff on my website.

 

Beyond that I have no reasons.

Link to comment
Share on other sites

Moosferatu,

 

to learn more about ruby read every word of the foreword and preface, then you can skim the rest of the chapters and zoom in to whatever catches your interest (notice the chapter on "ruby and the web"?). here is another good introduction to ruby and the official faq:

 

http://www.rubycentral.com/misc/intro.html

http://www.rubygarden.org/iowa/faqtotum

 

to compare ruby's syntax with other languages you can read the chapter on expressions. i think you'll notice how most everything makes sense without further explanation, even if you're not a com-sci major (like me); this is as close to english as you'll get in a programming language without sacrificing power. if you are interested in language comparisons then keep an eye out on this project:

 

http://pleac.sourceforge.net/

 

keep in mind that ruby is a relatively new language, though apparently it has been catching fire in japan for awhile (makes sense since that's where it was created). if you want to go with a popular language that might buff your resume, then go with java or some microsoft solution, but if you want to go with a refreshing language you can be passionate about that makes programming relatively easy and fun, then go with ruby.

 

i like to tell my colleagues: i used to make spaghetti with perl, went through my tab phase (or fetish) with python, put money on the table with java, played around with php, and now i dream of rubies :).

 

have fun in your coding endeavors!

 

-10bt

Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...