DanDaBeginner Posted July 31, 2007 Share Posted July 31, 2007 which is lighter? $var = 'hello world'; or define("VAR","hello world"); Im just wondering which one is much lighter? because im trying to make a config file... and saving disk space is really my concern right now.. thanks in advance... Link to comment https://forums.phpfreaks.com/topic/62624-which-is-lighter-variable-or-constant/ Share on other sites More sharing options...
Vizor Posted July 31, 2007 Share Posted July 31, 2007 A variable is simply a pointer to the memory where the actual variable contents are stored, the same with a constant, the only difference being that a constant can't be changed. It depends on what you're script is being used for, if it's being used alot then constants are to be avoided as php creates a new instance in the memory for each constant every time the script is run; for example if the script is accessed 5 times at the same time you end up with 5 constants in the memory. Not too sure how variables work in the same level of detail. Link to comment https://forums.phpfreaks.com/topic/62624-which-is-lighter-variable-or-constant/#findComment-311739 Share on other sites More sharing options...
DanDaBeginner Posted July 31, 2007 Author Share Posted July 31, 2007 thanks Vizor what a wonderful info you have share... any one else??? Link to comment https://forums.phpfreaks.com/topic/62624-which-is-lighter-variable-or-constant/#findComment-311754 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.