Results 1 to 2 of 2

Thread: PHP 'virtual ( )' giving error

  1. #1
    Join Date
    Nov 2008
    Location
    San Diego
    Posts
    31

    PHP 'virtual ( )' giving error

    Hello,
    I'm trying to use this to include a navigation bar on each of my pages.

    <?php virtual('/nav.php'); ?>

    However, whenever I try to view the page, it gives me an error, saying the function 'virtual()' is not defined.

    So, I tried using 'include ()', and 'require_once()' but those too, aren't working...

    to resolve the issue, I edited my nav.php file to just this:

    <a href="/egerg.com">ergre</a>
    <a href="/dfbd.com">dffbd</a>
    <a href="/nyrh.com">rhrttr</a>


    Still no luck....


    Any suggestions would be greatly appreciated! Thanks!

  2. #2
    Join Date
    Feb 2007
    Location
    Ireland
    Posts
    1,007
    The virtual function is for apache sub requests. Just ignore it, you don't need it for this.

    Your problem is your path. You have it set as "/nav.php". The forward slash implies the root directory of the system (I am assuming you are using a linux system), you will need to enter the absolute path or a relative path based on your current working directory.

    "nav.php" or "./nav.php" will include the file from the current directory
    "../nav.php" will include the file from the parent directory
    "includes/nav.php" will include the file from the includes directory (which is located in the current directory)

    PHP Code:
    <?php include('nav.php'); ?>
    Also just to note that you have /dfbd.com links in your html above too... this is fine, as the / will imply the document root, which is the root directory relative to the host. While the link may be wrong, it is still valid.

    http://www.example.com/dir1/dir2/dir3/index.html
    a link to /dfbd.com will point to http://www.example.com/dfbd.com
    “The best thing about a boolean is even if you are wrong, you are only off by a bit.”

Similar Threads

  1. open_basedir restriction in effect error in PHP
    By BenR41 in forum Client & Server Side Scripting (PHP, ASP, JavaScript)
    Replies: 1
    Last Post: 27 Feb 2008, 05:41 PM
  2. PHP and MySQL Error handling problems
    By LithMaster in forum Client & Server Side Scripting (PHP, ASP, JavaScript)
    Replies: 1
    Last Post: 23 Oct 2005, 05:51 PM

Posting Permissions

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