Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 4561760
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 21, 20262026-05-21T18:07:15+00:00 2026-05-21T18:07:15+00:00

At some point somebody suggested to me that the sluggishness in my PHP script

  • 0

At some point somebody suggested to me that the sluggishness in my PHP script could be partly because I was returning a large array from a function. Instead he suggested passing an object reference to the function and having the function working directly on the array.

If this makes a significant difference I’m planning on changing my function style to returning an array of information regarding the function execution (time benchmark, attempts etc.) and working directly on an object reference instead.

So what do you think?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-21T18:07:16+00:00Added an answer on May 21, 2026 at 6:07 pm

    No, it does not make any difference.

    PHP implements copy-on-write, meaning that even if you assign a value to another variable or return it from a function, the value is simply passed by reference internally. It’s only actually being copied when written to, and even then only if there are no other variables referencing it. Since you’re returning the array from a function, no other variables should reference the array, hence there’s no copying going on at any point.

    PHP does a lot of optimization with regards to pointers, references and variable handling. Don’t think you can outsmart it easily, PHP is too high-level for that. Write what you mean. And as always: profile to find the real bottlenecks.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Ok, so at some point in time, somebody checked in some files with names
I have a lot of constants that are somehow related, at some point I
Can anyone point to some code that deals with the security of files access
Could point me to some good links, or share experiences of the differences /
Could anyone could point me to some code/give me ideas on how to create
At some point in time I turned on a setting in Visual Studio 2005
I am designing a system which will at some point require to send email
I have recently reinstalled MacOSX, and at some point (without realizing it) I made
Searching for some sample code for converting a point in WGS84 coordinate system to
Can anyone point me in the right direction of some facial recognition libraries &

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.