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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T22:46:35+00:00 2026-06-17T22:46:35+00:00

I usually do this in PHP for better readability but I don’t know if

  • 0

I usually do this in PHP for better readability but I don’t know if it consumes memory or has any other issues? Let’s say I have this code:

$user = getUser(); // getUser() will return an array

I could do:

$email = $user["email"];
sendEmail($email);

Without declaring the variable $email I could do:

sendEmail($user["email"]);

Which one is better? Consider that this is just a very simple example.

  • 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-17T22:46:36+00:00Added an answer on June 17, 2026 at 10:46 pm

    Don’t make your code less readable just to save a few bytes. And this will not save you more, even if $email is a 100 MB string, because internally PHP uses the copy on write mechanism: The content of a variable is not copied unless you change it.

    Example:

    $a = str_repeat('x', 100000000); // Memory used ~ 100 MB
    $b = $a;                         // Memory used ~ 100 MB
    $b = $b . 'x';                   // Memory used ~ 200 MB
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

hello frieds this is how i usually post a variable using Jquery.. $.post(include/save_legatee.inc.php, {
I'm usually a lot better than this, I promise. Back story here: At my
$p = (isset($_REQUEST[p])?$_REQUEST[p]:); This is the common line I usually use in my php
I know that PHP CLI is usually used because of none time limits and
If a PHP script on the server can't create a directory, is this usually
I usually use this line to import file from out of the current folder
How would I usually represent this business logic in a graph? A is true
I have been seeing code like this usually in the start of header files:
I am rx this error on Deserialization: Invalid wire-type; this usually means you have
After creating a new form, I usually perform this ritual: Change the name into

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.