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

  • Home
  • SEARCH
  • 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 6325693
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T16:56:40+00:00 2026-05-24T16:56:40+00:00

Once I pass a variable inside a function as a reference, if I later

  • 0

Once I pass a variable inside a function as a reference, if I later access it, is it still a reference or..?

Example:

function one(){
    $variables = array('zee', 'bee', 'kee');
    $useLater =& $variables;
    two($variables);
}

function two($reference){
    foreach($reference as $variable){
        echo 'reference or variable, that is the question...';
    }
}

In function two(); are the variables here a reference to previously set $variables or a new element is created (in memory, I guess..)?

Plus, one more, is there a way to check if variable is passed by reference or not? (like: is_reference();)

  • 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-24T16:56:41+00:00Added an answer on May 24, 2026 at 4:56 pm

    A variable is only passed by reference (in current versions of PHP), if you explicitly pass it by reference using &$foo.

    Equally, when declaring a variable to a new variable, such as $foo = $bar, $foo will be a reference to $bar until the value changes. Then it is a new copy.

    There are lots of ways of detecting a reference here, maybe check some of them out. (Why you would need to do this is unknown, but still, it is there).

    http://www.php.net/manual/en/language.references.spot.php

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

Sidebar

Related Questions

My onclick function works beautifully when i pass one variable and doesn't respond once
OK, once again I need help. I have managed to pass a variable in
Once again one of those: Is there an easier built-in way of doing things
Once I've created a variable in the immediate window in C# (VS2008), is there
I need to create a structure inside a function (dynamically with malloc) Then i
I was wondering if it is possible to pass back a variable from fancybox
I have about 30 variables that I need to pass to 3 functions e.g.
Once a user starts a session (or logs in, for a registered user, to
Once again a very beginner-ish question, but here I go: I would like to
Once I have all the files I require in a particular folder, I would

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.