dhruvasagar Posted August 21, 2007 Share Posted August 21, 2007 I am a beginner in PHP programming so I apologize if this is a stupid question or something that has already been answered. My question is what is the scope of a function defined in a php file? If I want to call a function I defined in another file, do I need to do something like include that PHP file in this new PHP file or will it be just accessible? Though personally I think we'll need to include it of course... The problem in searching is that when I do search for this, I end up reading excerpts for function scope, i.e. scope of variables etc which are declared within a function, that's not what I am looking for, I want to know the scope of these declared functions... I have programming knowledge as well as experience in c/c++/java/VB/VC++/C#/ASP/Advanced Java/.NET etc...hence i understand most of the concepts of OOP as well as general programming. Quote Link to comment https://forums.phpfreaks.com/topic/65936-solved-scope-of-a-function-in-php/ Share on other sites More sharing options...
MadTechie Posted August 21, 2007 Share Posted August 21, 2007 this is a basic setup of using an external function <?php include "common.php"; hello(); bye("madtechie"); ?> common.php <?php function hello() { echo "hello world<br>"; } funtion bye($name) { echo "bye bye $name"; } ?> Quote Link to comment https://forums.phpfreaks.com/topic/65936-solved-scope-of-a-function-in-php/#findComment-329636 Share on other sites More sharing options...
dhruvasagar Posted August 21, 2007 Author Share Posted August 21, 2007 I thought so, I just wasn't able to confirm by searching because i wasn't getting proper results. Thanks a lot Quote Link to comment https://forums.phpfreaks.com/topic/65936-solved-scope-of-a-function-in-php/#findComment-329641 Share on other sites More sharing options...
MadTechie Posted August 21, 2007 Share Posted August 21, 2007 welcome can you please click topic solved (bottom left) save other reading this trying to help when its been solved and welcome to the board Quote Link to comment https://forums.phpfreaks.com/topic/65936-solved-scope-of-a-function-in-php/#findComment-329646 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.