Jump to content
  • Checkout
  • Login
  • Get in touch

osCommerce

The e-commerce.

-> Php Assignment Symbol?


RoseCamp

Recommended Posts

I am new to coding in PHP and have recently implemented an online store based on osCommerce. There is lots of great code to copy and/or learn from.

 

There are a couple of things that I can't find any info about on the PHP sites or elsewhere....

 

First thing:

The symbol -> is used in various places. It seems to be used to append something to an existing variable.

eg. in \includes\functions\general.php, about line 1033...

 

$message->build_message();

$message->send($to_name, $to_email_address etc)

 

Can anyone provide a link to an explanation of the -> symbol, just so I can confirm my assumption /and so I can figure out how I can't find a description for it?

 

Second query:

the send() in the above code example. I can't find an explanation of that either. I've searched my osCommerce source code, it doesn't seem to be a osCommerce function. ..

 

Thanks

Rose

Link to comment
Share on other sites

The $message variable represents an instance of a class. Send is a function in that class. The -> tells the code to look in the $message class and execute the function named send. If you look in includes/classes/message_stack.php, it might make more sense.

 

Jack

Support Links:

For Hire: Contact me for anything you need help with for your shop: upgrading, hosting, repairs, code written, etc.

All of My Addons

Get the latest versions of my addons

Recommended SEO Addons

Link to comment
Share on other sites

Thanks Jack.

That has cleared it up a bit for me, but I still can't find the definition for the class message. I have found class messagestack, but I wouldn't have thought that was the same thing.

I finally found the definition for the send function too. Don't know how I missed it first time.

 

So where is the $message class defined? or is it assumed, and the -> just tells it to go look for the send function?

 

I have finally found a bit of info in the PHP manual, thanks to your description. http://www.php.net/manual/en/functions.var...e-functions.php

 

Perhaps I just need to ponder on that for a bit.

 

Rose

Link to comment
Share on other sites

It's hard not to feel stupid... but I will ask the question!

 

Why is $messageStack the same as $message?

I would have thought that $message->send() was looking for a variable called $messageStack, not $message?

 

Rose

Link to comment
Share on other sites

It's not the same. I didn't pay enough attention to your original post. The $message or $messageStack or $anynameyouwant is an instance of whatever class it is created from using the new operator. You mentioned that $message was in the general.php file. So if you look in the function where it is used (assuming we are referring to the same code), you will see

$message = new email(array('X-Mailer: osCommerce Mailer'));

 

Jack

Support Links:

For Hire: Contact me for anything you need help with for your shop: upgrading, hosting, repairs, code written, etc.

All of My Addons

Get the latest versions of my addons

Recommended SEO Addons

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...