Please help with a little problem

Discussion in 'PHP' started by Mr.Bill, Jun 3, 2009.

  1. #1
    I am trying to add one line of code to a file so that I can multiple files in one location with the name example_com.php here is the basic idea what I am trying to do

    
    <?php 
    $string2 = str_replace('www.','' , '.','_',$_SERVER['HTTP_HOST']);
    include $string2.php; 
    ?>
    
    PHP:
    I am having an issue with the include its removing both dots I need it to remove only one and include the corresponding files.
     
    Mr.Bill, Jun 3, 2009 IP
  2. givemeknol

    givemeknol Active Member

    Messages:
    22
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    88
    #2
    include $string2 . ".php" ?
     
    givemeknol, Jun 3, 2009 IP
  3. jnugroho73

    jnugroho73 Peon

    Messages:
    77
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    0
    #3
    Actually I don't quite understand what you after is. what do you expect from the following code:

    
    <?php
    $string2 = str_replace('www.','' , '.','_',$_SERVER['HTTP_HOST']);
    include $string2.php;
    ?>
    
    Code (markup):
    I prefer use this:
    
    <?php
    $string2 = str_replace('www.','',$_SERVER['HTTP_HOST']);
    include("{$string2}.php");
    ?>
    
    Code (markup):
    But the result of the code is try to include any hostname that you place the code. For example:

    If you place the code in www.xx.com, then the code will include file xx.com.php

    Please give the detail information :confused:
     
    jnugroho73, Jun 3, 2009 IP