I have a php file which contains php function. I have to receive its return value in a part of my web page. Where do I put the include? in the head or in the body? how can I call the function inside my web page?
I have a php file which contains php function. I have to receive its
Share
You can include the php file wherever you want, as long as it is before you call the method contained in it. You call the function between
<?php ?>tags. You can useechoto output it to the page.So if you have
myfunc.phpthat looks like this:Then in php that includes it you can do:
You can also choose to put the
includemethod anywhere above that makes sense. The very top of the file is a common choice.Also note that if your php file contains functions, you should probably be using
require_onceinstead ofinclude. See: http://php.net/manual/en/function.require-once.php