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!

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.