alecjw Posted August 6, 2006 Share Posted August 6, 2006 Is it possible to define a variable ,then later on declare it global?eg:<?php$var="hello!";//some codeglobal $var; Link to comment https://forums.phpfreaks.com/topic/16741-globals/ Share on other sites More sharing options...
trq Posted August 6, 2006 Share Posted August 6, 2006 You only really need to use the global keyword from within functions anyway, but to answer your question, yes.[code=php:0]<?php $var="hello!"; function foo() { global $var; echo $var; } foo();?>[/code] Link to comment https://forums.phpfreaks.com/topic/16741-globals/#findComment-70403 Share on other sites More sharing options...
alecjw Posted August 6, 2006 Author Share Posted August 6, 2006 Thanks. Link to comment https://forums.phpfreaks.com/topic/16741-globals/#findComment-70406 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.