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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T09:25:22+00:00 2026-06-12T09:25:22+00:00

Often, I have seen functions being called like $content = getContent($isAdmin = false) Whereas

  • 0

Often, I have seen functions being called like

$content = getContent($isAdmin = false)

Whereas the function declaration is like

function getContent($isAdmin = true){
....}

Why would anyone add a overload of creating a variable and using it only once in a function call !!

I understand that this makes the function call clear, but shouldn’t we use PHPDoc blocks instead?

  • 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-12T09:25:23+00:00Added an answer on June 12, 2026 at 9:25 am

    I have the feeling that you are deeply shocked by so much “waste”.

    Keep cool, using variables is nothing bad, you should use them often. They normally make your code more descriptive and even faster.

    The more descriptive part is the case here, if you look at that line, you see which parameter that is because now it has a name.

    but shouldn’t we use PHPDoc blocks instead?

    Well, actually this is unrelated to (docblock) comments. Even in the function definition, there is no comment for that parameter:

    function getContent($isAdmin = true) {
    

    It’s just the definition of the parameter by it’s name. Also the docblock parameter would be only when you define the function:

    ...
     * @param $isAdmin bool (optional) true or false, true by default
    ...
    function getContent($isAdmin = true) {
    

    However that is not where the function is called:

    $content = getContent($isAdmin = false)
    

    So if you look at that line (and before pressing any hotkey or mouse button), you already read that. Nothing needed, only the code. Works even in notepad or an non-configured gedit.

    $nonAdmin = false;
    $content = getContent($nonAdmin);
    

    And btw, if your code needs comments, this is normally a sign that it is too complicated. Also the name of a parameter is much more important than it’s docblock. A good name normally means that you do not need to have a docblock tag for it (that means: less code to maintain), because the name speaks for itself.

    Also modern IDEs know the type of the parameter by static analysis and therefore you do not need the docblock tag either. So no, you do not just should always use PHPDocblocks.

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

Sidebar

Related Questions

I have often seen stylesheets written where you have something like this: #anyelement {
For debug logging, I have often seen and used something like #ifdef DEBUG #define
I have often seen people spawning new functions with arity 0 (no arguments) as:
I have often seen code examples of delegate invocation being done as follows: `
I have often seen the spinning gears OpenGL example ( I think originally done
I have often seen an init() within the constructor of AS3 classes, sometimes even
I quite often have rows of code like the following: UPDATE my_table SET name
I have seen it pretty often so far that for some reason the latitude
I have often seen cases where in a series of printf statements that ask
I have seen that queries like : user = User.objects.all() or User.objects.filter(username = username)

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.