/    Sign up×
Community /Pin to ProfileBookmark

"Include" help

I need help calling a function from a file that’s been included in the script. The function resides in the main page.

main.php

[code=php]
$animal = ‘Dog’;
function hello(){
global $animal;
print $animal;
}
include “b.php”
[/code]

b.php

[code=php]
hello();
[/code]

anyone?
thanks!

to post a comment
PHP

4 Comments(s)

Copy linkTweet thisAlerts:
@svidgenJun 22.2009 — The only thing I see wrong with your posted code is the omission of a semicolon after the include statement:
[code=php]$animal = 'Dog';
function hello(){
global $animal;
print $animal;
}
include "b.php"; // semicolon was missing here [/code]
Copy linkTweet thisAlerts:
@sushiauthorJun 22.2009 — hey there, that was just some sample code to illustrate my question.
Copy linkTweet thisAlerts:
@svidgenJun 22.2009 — You'll need to clarify the question then ... What [B]exactly[/B] is the problem?
Copy linkTweet thisAlerts:
@kurbyJun 23.2009 — There is nothing wrong with the method you posted. If there is an issue with your actual code it may be something else. Will need more info to help.
×

Success!

Help @sushi spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 5.15,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @AriseFacilitySolutions09,
tipped: article
amount: 1000 SATS,

tipper: @Yussuf4331,
tipped: article
amount: 1000 SATS,

tipper: @darkwebsites540,
tipped: article
amount: 10 SATS,
)...