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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 16, 20262026-06-16T22:21:59+00:00 2026-06-16T22:21:59+00:00

Possible Duplicate: How can arguments to variadic functions be passed by reference in PHP?

  • 0

Possible Duplicate:
How can arguments to variadic functions be passed by reference in PHP?

I need to get the values from the arguments of a method or function. I know i can do this with func_get_args(). But i really need to get the arguments by reference. Is there any way to do that?

I currently have this:

<?php
class Test
{
    function someFunc ( $arg1, $arg2 )
    {
        print_r ( func_get_args() );
    }
}

$t = new Test();
$t->someFunc('a1', 'a2');
?>

In my real code the argument values are passed to another class->method(). In there i want to be able to change the argument values. This would be possible if i could get the values as reference.

Is there a solution for this?

  • 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-06-16T22:22:00+00:00Added an answer on June 16, 2026 at 10:22 pm

    Nothing stopping you now .. just make it a variable instead if not PHP would return Fatal error: Cannot pass parameter 1 by reference

    class Test {
    
        function someFunc(&$arg1, &$arg2) {
            var_dump(func_get_args());
    
            $arg1 = strtoupper($arg1);
            $arg2 = strtoupper($arg2);
        }
    }
    
    echo "<pre>";
    
    $arg1 = "a1";
    $arg2 = "ar2";
    $t = new Test();
    $t->someFunc($arg1, $arg2);
    
    var_dump($arg1, $arg2);
    

    Output

    array (size=2)
      0 => string 'a1' (length=2)
      1 => string 'ar2' (length=3)
    
    string 'A1' (length=2) // modified
    string 'AR2' (length=3) // modified
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Possible Duplicate: PHP get all arguments as array? Well, In java I can do
Possible Duplicate: PHP get all arguments as array? Within a javascript function arguments always
Possible Duplicate: How can I get the name of function inside a JavaScript function?
Possible Duplicate: Get a function’s arity How can I declare a function expression, pass
Possible Duplicate: Can I pass an array as arguments to a method with variable
Possible Duplicate: How to pass arguments to addEventListener listener function? How can I pass
Possible Duplicate: How do I expand a tuple into variadic template function's arguments? “unpacking”
Possible Duplicate: How can I send two arguments in a selector method? I am
Possible Duplicate: What is the safest way of passing arguments from server-side PHP to
Possible Duplicate: Can I use a function to return a default param in php?

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.