Jump to content

Include Problem


ktalebian

Recommended Posts

Hi there,

for some reason, I am having problem accessing variables and functions that are in a file that is included in another:

 

fun.php
<?php
function Name()
{
   // doing stuff
   return $someVariable;
}
$string = 'something';

echo "This string says $string";
?>

page.php
<?php
include 'fun.php';
echo $string;
$test = Name();
?>

 

 

Now, when I run the code above, i don't get anything from echo $string. But, the echo "This string says $string" is displayed. I also get an Fatal error saying that the function I am referring to is not defined.

Why??

 

Thanks!

Link to comment
https://forums.phpfreaks.com/topic/103685-include-problem/
Share on other sites

Hi there,

I know the function is not doing anything, i just wrote it as an example.

 

I have WAMP installed on my PC (i want to finish the website before I upload it to the server). Could it be that some sort of a configuration is not setup correctly? Cause I am also getting problems with using SESSIONS!

 

Thanks!

Link to comment
https://forums.phpfreaks.com/topic/103685-include-problem/#findComment-531070
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.