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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T00:51:29+00:00 2026-06-13T00:51:29+00:00

I am new to php and have coding experience in java and C. So

  • 0

I am new to php and have coding experience in java and C. So optional parameter is a bit confusing for me. I would like to know that if a function has two optional parameters and if I pass a single argument, which parameter will be mapped against the argument?

  • 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-13T00:51:30+00:00Added an answer on June 13, 2026 at 12:51 am

    The first argument is always passed to the first variable in the parameters, the second to the second and so on, regardless of whether they are optional or not.

    The only difference between an optional and a non-optional parameter is that a warning is thrown when there are not enough arguments in the call to fulfill all non-optional parameters.

    function f($a = 1, $b, $c, $d = 2)
    {
      var_dump($a, $b, $c, $d);
    }
    f('x');
    

    Inside the function $a will be “x”, $b and $c will be null and $d will be 2 but a warning will be thrown.

    Therefore it makes no sense to have optional parameters left of non-optional ones – although that would be syntactically correct – because you could never leave them out in the call without generation a warning.

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

Sidebar

Related Questions

I am fairly new to coding in php and have come accross a bit
I'm new to php and web coding so any help would be great. I'm
I am somewhat new to PHP coding and I am aware that malicious users
I am new to php and am asking for some coding help. I have
Hey I'm new to PHP so would really like your insight on how I'm
i am new in php i have a problem in my php code.please help
I'm quite new to php and have been reading Larry Ullman book to develop
I'm pretty new to PHP and have a String which contains an HTML page.
Hi I am new to PHP and have a simple problem but I have
I'm very new to PHP and I have a small task of displaying a

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.