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 6031647
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T05:12:54+00:00 2026-05-23T05:12:54+00:00

Well, I read in my handy PHP book that it’s very important to be

  • 0

Well, I read in my handy PHP book that it’s very important to be able to distinguish between reference and variable parameters. The book says that the original value of parameterized variables are preserved when the variable is changed, and the original values of parameterized references change when the reference is changed. It says that’s the key difference, if I am reading right.

Well, I’m wondering when each is more useful than the other. How do I know when to use variables and when to use references when I create my own functions?

  • 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-23T05:12:55+00:00Added an answer on May 23, 2026 at 5:12 am

    “References” (variable aliases) make your code harder to understand and could be a source of hard to follow errors. There are no valid reasons to use references in php and to be on the safer side try to avoid them altogether.

    And no, objects in php5 have nothing to do with “references”.

    “References” as implemented in php is a strange concept. Normally, in programming languages variables are independent of each other so that changing one variable doesn’t affect others. Php “references” allow several variables to share the same value and to be dependent of each other. Basically, you change one variable, and suddenly another one, which you think is totally unrelated, is getting changed too. It’s no good thing and often leads to much confusion.

    Objects in php (do I need to add ‘five’?) have nothing to do with “references” in the above sense. They behave much like C pointers (actually, this is what they are under the hood) – when you pass an object to a function, you actually pass a pointer, and the function can use this pointer to manipulate the object contents, but there’s no way for the function to change the passed variable itself, for example, make it point to another object.

    This “objects are references” misunderstanding is probably because people confuse php “references” (ampersand syntax) with the generic CS term , which also applies to pointers, handles etc.

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

Sidebar

Related Questions

I want to be able to read any well-formed RSS/ATOM file. That would mean
Well, first I should probably ask if this is browser dependent. I've read that
A have read about A* as well as D* and similar, and i'm not
Well is there? From everything I've read, it seems like the answer is no,but
I recently read a post about no longer needing to declare ivars as well
Well, I am abit confuse using these \r,\n,\t etc things. Because I read online
I have previously read Spolsky's article on character-encoding, as well as this from dive
It seems to be well-known there is a bug when using JMenuItem.getRootPane(). I read
Is Scala a good choice to implement a well scalable MMORPG? I read about
I see lots of php libraries that can parse html. A nice example is

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.