No announcement yet.

php includes

  • Filter
  • Time
  • Show
Clear All
new posts

  • #16
    "header.php" tries to access a file named "header.php" within your current working directory, whereas "../header.php" tries to access a file of the same name in the parent directory. You can also access files in other directories such as "../layout/header.php".

    Also, you do not need to rename any of your file extensions. If all you files are .html, simply add that extension to your http server's list of extensions that are applicable to PHP pre-processing. .php, .php3, .htm, .html or anything else you add to that line is scanned for PHP code to be executed before it is sent to the client's browser. You will need access to and knowledge of your PHP configuration within your http server to accomplish this. For example: "AddHandler application/x-httpd-php .html" in Apache.

    Also, includes can be of any file type, even no file type. PHP is simply looking for a file as referenced and including it's content. This is an excellent way to have a file export:

    PHP Code:
    header'Content-type: application/pdf' );
    header"Content-Disposition: attachment; filename=\"{$_GET'filename' ]}.pdf\"" );
    "../../resources/userfiles/{$_SESSION'userinfo' ][ 'userid' ]}.pdf"


    • #17
      You could try this:

      PHP Code:
      <?php include(""); ?>
      But why the "../" doesn't work is beyond me :\


      • #18
        Originally posted by c-a-a View Post
        i always use a doc root
        PHP Code:
        <? include ($DOCUMENT_ROOT . '/your/nav/file.htm');?>
        which is better? does it matter?
        Well $DOCUMENT_ROOT is deprecated and shouldn't be used. You should be using


        instead. it doesn't matter which one you use in your choice.
        Have a Script or Snippet you want to share?

        WWW Standards: HTML 4.01,
        HTML 5, CSS2.1, CSS3, XHTML 1.0
        PHP Standards: PHP Standards