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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 16, 20262026-06-16T00:49:26+00:00 2026-06-16T00:49:26+00:00

Regarding PHP functions, if you do not need a function to return a BOOLEAN

  • 0

Regarding PHP functions, if you do not need a function to return a BOOLEAN or STRING, is there a difference between declaring a return on failure of a condition, rather than just letting the function automatically return?

For example,

Is there any internal difference between:

function check() {
    if( 5 > $v ) {
        die('yes');
    }
}

function check() {
    if( 5 > $v ) {
        die('yes');
    }
    else {
        return;
    }
}

Obviously, they appear to do the same exact thing on failure of the ‘IF’ condition, but internally, is one better than the other in for sake of memory, security, usability, or overall best practice?

  • 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-16T00:49:27+00:00Added an answer on June 16, 2026 at 12:49 am

    There is no effective, real-world difference in these statements in terms of memory or security. None, nada, zip, zero. They are completely identical. The few bytes needed to hold the additional opcodes is irrelevant, and if you care about the time spent parsing, tokenizing and interpreting the opcodes, you are engaging in micro-optimization.

    In terms of “usability”, the former is more clear by far. Returning from the else is silly. If I saw that in live code, I’d assume that whoever wrote it was distracted when doing so and clean it up.

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

Sidebar

Related Questions

This question is regarding getopt function in php. I need to pass two parameter
I want to return multiple values from a PHP function, but it did not
I have a question regarding static function in php. let's assume that I have
Here's something interesting I've just found out regarding str_replace(). In my function I need
Which php array function should be used to match a string to the first
It's clear from reading through threads that I can call a PHP function using
Regarding PHP security with cookies and sessions, this is what i have done so
I think that I've been used to a fairly liberal policy regarding the PHP
I have a question regarding the proper way to modify a php DateTime object.
I have read the PHP manual , but couldn't find any proper explanation regarding

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.