www.webdeveloper.com
Results 1 to 2 of 2

Thread: Error calling function from included file

  1. #1
    Join Date
    Jan 2011
    Posts
    16

    Error calling function from included file

    I have the following PHP script
    PHP Code:
    <?php
    $contentpage 
    "http://www.example.com/about/page.php";
    require(
    "http://www.example.com/passprotect.php");
    if (
    function_exists('showpage'))
        {
        echo 
    "2: function declared";
        }
    else
        {
        echo 
    "2: function not declared";
        }
    showpage();
    ?>
    And http://www.example.com/passprotect.php contains
    PHP Code:
    <?php
    function showpage()
        {
        
    /*
        A long is function for password protected webpages
        ...
        */
        
    if ($passValid)
            {
            require(
    $contentpage);
            }
        }
    if (
    function_exists('showpage'))
        {
        echo 
    "1: function declared";
        }
    else
        {
        echo 
    "1: function not declared";
        }
    ?>
    The function is declared when the second PHP page is require()'d but then it creates an error when I try and call it again.
    Is there anything I can do about this?

  2. #2
    Join Date
    Jan 2011
    Posts
    16
    I am relatively new to PHP so please excuse any stupid mistakes

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
HTML5 Development Center



Recent Articles