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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T18:13:02+00:00 2026-05-25T18:13:02+00:00

Setting variable values inside a function call – I don’t see this a lot,

  • 0

Setting variable values inside a function call – I don’t see this a lot, is this considered good practice?

function myUpdate($status){
    ...
}

myUpdate($status = 'live');

I personally like it because it’s more descriptive. I see it more frequently the other way around, ie., assigning a default value in the function definition.

  • 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-25T18:13:03+00:00Added an answer on May 25, 2026 at 6:13 pm

    That’s a very bad idea, because it’s basically code obfuscation. php does not support keyword arguments, and that can lead to weird stuff. Case in point:

    function f($a, $b){
        echo 'a: ' . $a . "\n";
        echo 'b: ' . $b . "\n";
    }
    f($b='b-value', $a='a-value');
    

    This program does not only output

    a: b-value
    b: a-value
    

    but also defines the variables $b and $a in the global context. This is because

    f($b='b-value', $a='a-value');
    // is the same thing as ...
    $b = 'b-value';
    $a = 'a-value';
    f($b, $a);
    

    There are a few good practices one can do to make remembering method arguments easier:

    • Configure your editor/IDE to show the signature of functions on highlight.
    • If a function has lots of arguments that describe some kind of state, consider moving it into an *objec*t (that holds the state instead)
    • If your function just needs lots of arguments, make it take an array for all non-essential ones. This also allows the method caller not to worry at all about the multitude of options, she just needs to know the ones she’s interested in.
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have variable @count of datatype int.I am setting values to this @count. I
I am setting a session variable inside a function studNameDetails1() while I am trying
Is there anything wrong with setting a Rails variable inside a javascript function? I
I'm setting two local variables inside of a jQuery .load(function(){...}) handler, but I can't
I am having a problem setting the Authorize attribute Role value from a variable.
How can I have a dynamic variable setting the amount of rows to return
I've got a choose statement that should be setting my variable but for some
I am working in flex and I am just setting a variable to false.
I must be overlooking something simple. I'm setting a variable from a query result
I am copying a file to a directory, and then setting an environment variable

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.