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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 2, 20262026-06-02T13:34:49+00:00 2026-06-02T13:34:49+00:00

I know that in PHP when you want the function parameters to reference target

  • 0

I know that in PHP when you want the function parameters to reference target variables we use the ampersand & sign. But I can not figure out if it is still valid and reliable in the following scenario (where variables are gathered from a request).

$v1 = $_POST['v1'];

function filled(&$var) {
    return isset($var) && !empty($var);
}

if (!filled($v1)) // etc.

or even in this scenario:

$v1 = $_POST['v1'];
$v2 = $_POST['v2'];

function filled() {
    $args = &func_get_args(); // does this even take the references and not the values?
    foreach ($args as &$arg) {
        if (empty($arg) || !isset($arg)) return false;
    }
    return true;
}

if (!filled($v1, $v2)) // etc.

Thanks in advance for clarification.

  • 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-02T13:34:52+00:00Added an answer on June 2, 2026 at 1:34 pm

    It is still valid since references don’t care if the variables are user defined or come from PHP superglobals, but there are a couple of issues with your first example.

    First, when you do $v1 = $_POST['v1']; $v1 is now independent of the $_POST['v1'] variable. Any changes to $v1 are not reflected in $_POST['v1'] because you made a copy.

    You could do: $v1 = &$_POST['v1']; to create a reference to it.

    Second, your call to isset in the function will always return true. isset is a special language construct, and not a function. If $_POST['v1'] is unset, $v1 will still be set (but will be null) after the assignment of $_POST['v1'] to $v1.

    Also, as far as I know, func_get_args() doesn’t support references, all the values it returns are copies of the original.

    Does that clear up some of your questions? If not, feel free to ask on anything you want clarified.

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

Sidebar

Related Questions

I want to know that whether on a php page we can get browser
I use the PHP language for file upload and want to know that the
I want to post some binary data to PHP. I know that I can
I want to use my custom PHP function CalculateAge which takes 3 parameters (day,
i want to know that how to get multiple selectbox values in php means
I'm new to AJAX and PHP but I know that PHP is a server-side
I know that it's not possible to style any given PHP but I do
Actually I don't know that there is available any php function to crop and
Possible Duplicate: PHP - I want to know how to get function trace I
I know that PHP is compiled to byte code before it is run on

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.