dennismonsewicz Posted September 23, 2009 Share Posted September 23, 2009 can someone explain what the declare statement is used for? I read about it in the PHP manual but I am not fully grasping the concept. http://us2.php.net/manual/en/control-structures.declare.php Link to comment https://forums.phpfreaks.com/topic/175273-php-declare-statement/ Share on other sites More sharing options...
nuttycoder Posted September 23, 2009 Share Posted September 23, 2009 It's used to make a date a constant meaning it never changes which is available throughout the script without a need to use the global. It's mainly used on config files for you database connection data for example. Link to comment https://forums.phpfreaks.com/topic/175273-php-declare-statement/#findComment-923766 Share on other sites More sharing options...
dennismonsewicz Posted September 23, 2009 Author Share Posted September 23, 2009 hmmm ok... is it really a helpful function? Link to comment https://forums.phpfreaks.com/topic/175273-php-declare-statement/#findComment-923771 Share on other sites More sharing options...
nuttycoder Posted September 23, 2009 Share Posted September 23, 2009 it can be, I din't use it at all until recently I use it a lot to store things like file paths. Instead if having to pass variables to a functions it's already available. I recommend giving it a try. Link to comment https://forums.phpfreaks.com/topic/175273-php-declare-statement/#findComment-923773 Share on other sites More sharing options...
dennismonsewicz Posted September 23, 2009 Author Share Posted September 23, 2009 but how does this function differe from using the define function? Link to comment https://forums.phpfreaks.com/topic/175273-php-declare-statement/#findComment-923774 Share on other sites More sharing options...
knsito Posted September 23, 2009 Share Posted September 23, 2009 Youre right.. declare() and define() are different I've never used declare() before but the tick option looks useful for debugging or monitoring something. Not really sure how to use the encoding part either.. Maybe someone else can shed some light on this. But this is something you probably woudnt use much, if ever.. but how does this function differe from using the define function? Link to comment https://forums.phpfreaks.com/topic/175273-php-declare-statement/#findComment-923808 Share on other sites More sharing options...
nuttycoder Posted September 23, 2009 Share Posted September 23, 2009 oh sorry I misread your first post I thought you said define when you said declare, I've never used declare. Link to comment https://forums.phpfreaks.com/topic/175273-php-declare-statement/#findComment-923813 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.