+ Reply to Thread
Results 1 to 8 of 8

Thread: Convert Include to php include

  1. #1
    Join Date
    Dec 2006
    Location
    Panama City Beach, FL 32413
    Posts
    46

    Cool Convert Include to php include

    hi folks,
    I am slowly converting my site to use .php pages. It is currently using includes and .shtml and .html pages.

    What is the code for the following include coverted to a php include?

    <!--#include virtual="/my-directory/mypage-to-be-included.html"-->
    Kind regards, Mike Foate - Buy, Sell, Prosper!

    Panama City Beach Real Estate-Homes, Condos and Land For Sale

    Mike's cell: 850-596-4236

    Mike and Vivian Foate-REALTORSŪ
    Prudential Shimmering Sands Realty
    7923 Panama City Beach Parkway
    Panama City Beach, FL 32407

  2. #2
    Join Date
    Apr 2007
    Location
    Austin, Tx
    Posts
    60

    Default Re: Convert Include to php include

    The easiest way would be:

    PHP Code:
    <?php require_once("\my-directory\mypage-to-be-included.html"); ?>

  3. #3
    Join Date
    Mar 2007
    Location
    Tucson, AZ
    Posts
    173

    Default Re: Convert Include to php include

    I think include_once() may be a better option, IIRC if the resource is not found using require_once() or require() it may throw an error and not render the rest of the page.
    Michael Krotchie - REALTORŪ - Coldwell Banker Residential Brokerage, NRT LLC
    6970 N. Oracle Road, Suite 100
    Tucson, AZ 85704
    520.404.4996 -- Mobile
    520.544.4545 -- Office

    Tucson Real Estate | Tucson Real Estate Blog

  4. #4
    Join Date
    Dec 2006
    Location
    Panama City Beach, FL 32413
    Posts
    46

    Default Re: Convert Include to php include

    geez you guys are quick! I guess I'll wait until the dust settles because we got differing opinions... ;-)

    Is ok to include .html pages in a .php page?
    Kind regards, Capt. Mike

  5. #5
    Join Date
    Apr 2007
    Location
    Austin, Tx
    Posts
    60

    Default Re: Convert Include to php include

    That is correct, you'll get a error if your path is named wrong.

  6. #6
    Join Date
    Mar 2007
    Location
    Tucson, AZ
    Posts
    173

    Default Re: Convert Include to php include

    I put up a couple example pages to show the difference; and yes, it is okay to include .html pages in a .php page... I do it all the time.

    Example using require_once()
    www (dot) michaelkrotchie.com/require_once.php
    Code:
    <?php 
    
    require_once("nothere.html");
    
    ?>
    Example using include_once()
    www (dot) michaelkrotchie.com/include_once.php
    Code:
    <?php 
    
    include_once("nothere.html");
    
    ?>
    So it displays an error either way, just depends how you want to handle the rest of the page. If you have the file there it doesn't really matter I think.
    Last edited by mkrotchie; 06-01-2007 at 12:33 PM. Reason: not sure if I am allowed to direct link to my site.. subsituted (dot)
    Michael Krotchie - REALTORŪ - Coldwell Banker Residential Brokerage, NRT LLC
    6970 N. Oracle Road, Suite 100
    Tucson, AZ 85704
    520.404.4996 -- Mobile
    520.544.4545 -- Office

    Tucson Real Estate | Tucson Real Estate Blog

  7. #7
    Join Date
    Dec 2006
    Location
    Panama City Beach, FL 32413
    Posts
    46

    Thumbs down Re: Convert Include to php include

    Heck you guys are GREAT! :-)

    Thanks for your help! Now I gotta figure out how to slowly migrate the pages with the extensions changed from .shtml to .php and not get dinged too bad in the search engines.

    I suppose I should research and see if there is some sort of mod rewrite solution...

    Thanks you guys! Have a GREAT weekend!
    Kind regards, Capt. Mike
    Last edited by Capt. Mike; 06-01-2007 at 01:00 PM.

  8. #8
    Join Date
    Nov 2006
    Posts
    109

    Default Re: Convert Include to php include

    Here is some code you can play with. Place it in a page, then call up that page in a browsers something like this -www.your-domain.com/your_page.php/1/2/3/4/5/6 and you will see how it works. I put a few "echos" in there so you can see waht it does. Change the browser url to www.your-domain.com/your_page.php/6/5/4/3/2/1 and you'll see it.

    I've used that system quite a bit and have good luck with it.

    SE friendly urls - http://www.sitepoint.com/article/sea...riendly-urls/2

    Here's the code

    <?
    $file=eregi_replace($_SERVER['SERVER_NAME'], "", $_SERVER['PHP_SELF']);
    $var=explode("/", $file);


    $affiliate_num_test = $var[3] ;//repnaming header_ID
    echo '$affiliate_num_test = ', $affiliate_num_test;?><BR><?
    $url_cat = $var[4] ;
    echo '$url_cat = ', $url_cat;?><BR><?
    $cat_record_num = $var[5] ;
    $cat_page_total = $var[6] ;
    $cat_page_id = $var[7] ;
    $link_page_id = $var[8] ;
    $link_page_total = $var[9] ;
    $link_record_num = $var[10] ;
    echo 'link_record_num = ', link_record_num;?><BR><?

    include("http://Bungeebones.com/link_exchange/index.php/$affiliate_num/$url_cat/$cat_record_num/$cat_page_total/$cat_page_id/$link_page_id/$link_page_total/$link_record_num");

+ Reply to Thread

Posting Permissions

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