Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 5 of 5
  1. #1
    Regular Coder ajhauser's Avatar
    Join Date
    Nov 2007
    Location
    Earlville. It's where Earls come from.
    Posts
    226
    Thanks
    74
    Thanked 1 Time in 1 Post

    Crawling PHP includes?

    Hello, I am new to includes and I see that when you look at the source code of a page that loaded with PHP includes, all the code is displayed. Does this mean that search spiders will crawl the data that is being included?

    For example:
    Code:
    <!DOCTYPE ...>
    <html>
    ...
    <body>
    <?php include('/path/to/include.ext');?>
    </body>
    I would imagine one would use a template to include the basic data for a page, like the meta data, etc. - but if you included the meta data in a PHP include, would that be crawled as well?



    On a slightly different note - aside from building a completely dynamic, database driven site, is there any better option for site-wide-updates than PHP includes? I have already found them to be better than Server Side Includes and Templates (which update an entire site, but requires the re-uploading of EVERY file on the site).

    THANK YOU!
    -AJ

  • #2
    God Emperor Fou-Lu's Avatar
    Join Date
    Sep 2002
    Location
    Saskatoon, Saskatchewan
    Posts
    16,987
    Thanks
    4
    Thanked 2,660 Times in 2,629 Posts
    If you're code is being displayed, then the page isn't being parsed as php - make sure the extension is .php. If the code is html code, that is fine. The page requested includes the definitions from the included file and is seen as the whole picture, not as parts.
    PHP Code:
    <?php
    // menu.php
    // Something really simple:
    session_start();
    if (!isset(
    $_SESSION['loggedin']))
    {
        
    printf("<a href=\"%s\">%s</a>\n"'login.php''Login');
    }
    ?>
    PHP Code:
    //Index
    <?php
    session_start
    ();
    ?>
    <!DOCTYPE...>
    <html>
    <head>
    </head>
    <body>
        <?php include dirname(__FILE__) . '/./menu.php';
    </
    body>
    will be seen as:
    Code:
    <!DOCTYPE...>
    <html>
    <head>
    </head>
    <body>
        <a href="login.php">Login</a>
    </body>
    Other than PHP, you can approach a client side method instead using XML and XSLT processing. This provides the client with an entire XML document, and formatting provided by the XSLT stylesheet. PHP also has an interpreter in it (xsl or xslt extension) that lets you convert the result to plain html (we needed this back in the day when xml wasn't supported properly by the browsers).

    That all make sense?
    PHP Code:
    header('HTTP/1.1 420 Enhance Your Calm'); 

  • #3
    Regular Coder ajhauser's Avatar
    Join Date
    Nov 2007
    Location
    Earlville. It's where Earls come from.
    Posts
    226
    Thanks
    74
    Thanked 1 Time in 1 Post
    It KIND of makes sense - my problem is I'm so new still... not your typing. Let me be a little more specific:

    My entire page called "index.php", is is located HERE and the code is LITERALLY:

    Code:
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml">
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <title>php</title>
    </head>
    
    <body>
    <?php include('includes/nav.html'); ?>
    </body>
    </html>
    My include "nav.html" is simply:

    Code:
    <a href="#">Home</a> | <a href="../about.php">About Us</a> | <a href="#">Link 3</a>
    NOTE: the links are broken - they aren't relevant for this.

    Now, when I look at the source code - it displays as follows:

    Code:
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml">
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <title>php</title>
    </head>
    
    <body>
    <a href="#">Home</a> | <a href="../about.php">About Us</a> | <a href="#">Link 3</a></body>
    
    </html>
    My question is when Google crawls the site (for example) does is "see" the source code, or will it only see the first example of code with the "<?php include('includes/nav.html'); ?>" - ?

    Hopefully that makes sense - thank so much for your help, it has been invaluable to me.

  • #4
    Supreme Master coder! abduraooft's Avatar
    Join Date
    Mar 2007
    Location
    N/A
    Posts
    14,855
    Thanks
    160
    Thanked 2,223 Times in 2,210 Posts
    Blog Entries
    1
    Google or any other search engines are just like a normal user. They can't see the PHP or the server side code. They only see the parsed html output.
    The Dream is not what you see in sleep; Dream is the thing which doesn't let you sleep. --(Dr. APJ. Abdul Kalam)

  • Users who have thanked abduraooft for this post:

    ajhauser (05-01-2009)

  • #5
    Regular Coder ajhauser's Avatar
    Join Date
    Nov 2007
    Location
    Earlville. It's where Earls come from.
    Posts
    226
    Thanks
    74
    Thanked 1 Time in 1 Post
    OK that completely answers my question - thank you.


  •  

    Posting Permissions

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