Jump to content

Question on PHP variables.


art15

Recommended Posts

Hi All,

 

If in php file, I need to have a variable printed <?php print $username; ?> where $username="User Name", is it that using <?php print $username; ?> consume more memory. Instead if I just write "User Name" on my php page without using a variable file to store the $username variable and using that variable file to echo the string User Name.?

 

Thanks

Link to comment
Share on other sites

First off, that is the most headache inducing description I've ever read.

 

Secondly, does $username change (it's pulled from a mysql table, determined from a POSTed value, etc)?  If not, why are you putting it in a variable to begin with?  I can only assume it is dynamic, in which case, it has to be a variable.

 

Memory wise, yes, it will consume a few bytes more, but nothing worth even noting.

Link to comment
Share on other sites

Memory wise, yes, it will consume a few bytes more, but nothing worth even noting.

 

I agree. it does consumes some memory but it's not something you should worry about, unless you are using oldest computer :).

 

If that is something that does not change, then I wont store it at the variable. If it is a magic number, I will make it a constant instead.

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.