art15 Posted June 25, 2008 Share Posted June 25, 2008 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 Quote Link to comment https://forums.phpfreaks.com/topic/111760-question-on-php-variables/ Share on other sites More sharing options...
hitman6003 Posted June 25, 2008 Share Posted June 25, 2008 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. Quote Link to comment https://forums.phpfreaks.com/topic/111760-question-on-php-variables/#findComment-573724 Share on other sites More sharing options...
bluejay002 Posted June 25, 2008 Share Posted June 25, 2008 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. Quote Link to comment https://forums.phpfreaks.com/topic/111760-question-on-php-variables/#findComment-573726 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.