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]

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.

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.

 

Archived

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

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