Page 1 of 1

What are the -> and :: operators?

Posted: Mon Mar 02, 2009 11:49 pm
by terminator24h
Just took on a job managing a site with a PHP/MySQL backend. Very simple question that I can't solve for the life of me. What do the -> and :: operators do?

Here they are in context:

Example 1:

// populate $schedules->moveout and $schedules->movein for filter list

$schedules->moveout = admin_dataAdapter::get_schedules_all($adminuser->school_list,'moveout');
$schedules->movein = admin_dataAdapter::get_schedules_all($adminuser->school_list,'movein');

Example 2:

foreach($adminuser->school_list as $school)

My best guess is that -> points to an element of an array that's specified with a name?

Any help is much appreciated. Thank you for tolerating my n00bieness.

Re: What are the -> and :: operators?

Posted: Mon Mar 02, 2009 11:56 pm
by terminator24h
Of course, immediately after posting, I discovered that -> refers to a variable within an object:

$object->$var = 5;

sets the $var variable of in $object to 5.

Question still stands for ::

Thanks.

Re: What are the -> and :: operators?

Posted: Tue Mar 03, 2009 12:33 am
by josh
:: is static operator. -> isnt specific to variables. If your job is serious you should probably consider resigning now and save yourself the embarrassment, after you learn what you're doing there'll be plenty of opportunity for work. Not that you're not a very bright individual or anything but how would you feel if someone represented themselves as a car expert then you found out later they were asking their colleagues what the battery is for? You'd probably feel pretty scammed, wouldn't you?

Re: What are the -> and :: operators?

Posted: Wed Mar 04, 2009 1:31 am
by terminator24h
Tremendously appreciated, thank you.

I take your advice to heart, but, with all due respect, I think you underestimate the extent to which knowledge of other programming languages can accelerate the learning curve. The way PHP deals with classes and objects is so similar to Java that I, as a somewhat-experienced Java programmer, can understand the code very easily once someone tells me what the weird operators here and there (like ::) do. It's not a heavy job by any standard -- upgrading a backend for a student-run summer storage company to accomodate another table in the database -- but it is serious (in that they will lose money if I don't do it).

Anyway, no flame intended.

Cheers :drunk:

Re: What are the -> and :: operators?

Posted: Wed Mar 04, 2009 9:11 am
by josh
Good stuff, you got to realize how many people take on projects they can't handle and come on here asking for help, sorry to grill you!