ecopetition Posted July 29, 2008 Share Posted July 29, 2008 How do I define a variable in a file for use in a function within another file? Link to comment https://forums.phpfreaks.com/topic/117172-define-a-variable-in-one-file-for-use-in-another/ Share on other sites More sharing options...
samshel Posted July 29, 2008 Share Posted July 29, 2008 same way as you normally do, if you are including that file before using, it should work... file1.php $myname = "SamShel"; file2.php include "file1.php"; echo $myname;//displays SamShel. Link to comment https://forums.phpfreaks.com/topic/117172-define-a-variable-in-one-file-for-use-in-another/#findComment-602680 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.