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
https://forums.phpfreaks.com/topic/111760-question-on-php-variables/
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.

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.

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.