Jump to content

Recommended Posts

Actually i have a very large object thats persistent using sessions. That object have two large arrays, and other things. I have to extract each time that arrays.

 

Now im using:

  $configuracion = $_SESSION['reg']->GetInvConfig();

  $categorias = $_SESSION['reg']->GetInvCategorias();

 

But if i get it well, this is copying all the array each time, no? i can use a reference to that array in the object easily to improve performace?

Link to comment
https://forums.phpfreaks.com/topic/236846-using-php-references/
Share on other sites

That's correct. You would need to add an ampersand at the assignment and within the function declaration, to return and assign by reference:

 

[...]
    public function &GetInvConfig() {
[...]

$configuracion = &$_SESSION['reg']->GetInvConfig();

 

Although the arrays would have to be large to make much of a difference to the memory usage. Also just be aware that any changes you make to the array would be reflected within the object.

That's correct. You would need to add an ampersand at the assignment and within the function declaration, to return and assign by reference:

 

[...]
    public function &GetInvConfig() {
[...]

$configuracion = &$_SESSION['reg']->GetInvConfig();

 

Although the arrays would have to be large to make much of a difference to the memory usage. Also just be aware that any changes you make to the array would be reflected within the object.

 

They can be large, anyway changue it is 1m and 0 if i know it on now.

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.