Jump to content

Passing values out of a function by reference???


skrappy1979

Recommended Posts

Ok, starting around line 137 with the functions..... Commented well. Just not sure If im doing it right. Any help greatly appreciated. Basic stuff and still learning. Just trying to figure out if Im passing by reference correctly or if not how to do it. Thanks. php File is attached but heres a snippet. Thanks in advance.

Peace,

Adam

 

// The grand total and the item total need to be passed BY REFERENCE.

 

function show_table_contents($cart_items, $table, &$grand_total, &$item_total)

 

[attachment deleted by admin]

Link to comment
Share on other sites

Ok, starting around line 137 with the functions..... Commented well. Just not sure If im doing it right. Any help greatly appreciated. Basic stuff and still learning. Just trying to figure out if Im passing by reference correctly or if not how to do it. Thanks. php File is attached but heres a snippet. Thanks in advance.

Peace,

Adam

 

// The grand total and the item total need to be passed BY REFERENCE.

 

function show_table_contents($cart_items, $table, &$grand_total, &$item_total)

 

Yes, that's how you do it.

Link to comment
Share on other sites

Thanks for the replys. I just wasnt sure. Sometimes it can look right but still be all wrong, lol.

 

Glad to help.  Just to clarify, you are actually passing values TO the function by reference so the function is actually modifying the variable that you passed.  Returning a reference is different, you return a reference to something created in the function (must be persistent) like an object var or something.

 

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

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

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  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...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.