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; Quote Link to comment 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] Quote Link to comment Share on other sites More sharing options...
alecjw Posted August 6, 2006 Author Share Posted August 6, 2006 Thanks. Quote Link to comment 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.