Jump to content

[SOLVED] Problems with return value from function in included php file


eternallygeek

Recommended Posts

I am having problems with some PHP code that I am writing.  I have a function in a separate php that is included in another php file with html (both shown below).  I obviously see the "test() returns...." text but not the return value of 5 from the function.  Any thoughts or nudges in the right direction?

 

Here is the html 'calling code'....  (test.php)

<html>
<?php 
include '/scripts/testing.php'
?>
<head>
    <title>stuff</title>
</head>

<body>
    <p>test() returns....</p>
    <?php echo test(); ?>
</body>
</html>

 

Here is the php function library.... (testing.php)

<?php

function test()
{
    return "5";
}

?>

 

Thanks!

Thanks for the reply AlexWD!

 

The semi missing was a typo, I reduced the code down for ease of debugging and placing on the forums here.

 

You were right in pointing me to the included file.  I moved the include file into the same directory and included just the filename in quotes.  That worked just fine, so there was something wrong with the path.  Now I just need to go off and figure out the right path on my webserver so that I can put that file back where I intended it.

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.