1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

Converting html to php

Discussion in 'General Programming Chat' started by welshman, Feb 26, 2010.

  1. welshman

    welshman Power Member

    Joined:
    May 9, 2009
    Messages:
    701
    Likes Received:
    190
    I'm considering converting my website that I started about 8 years ago from html to php. The things is, because it is so old, it's been tacked on bits and pieces and is now currently 200 pages. I do not have the time or the desire to do everything manually. Did a search on google.

    Found this solution:

    Code:
    http://www.visitor-stats.com/articles/convert-html-website-php.php
    Could anyone tell me if this is possible? Would it work? Or anyone have a better solution?

    Thanks.
     
  2. kaidoristm

    kaidoristm Power Member

    Joined:
    Feb 13, 2009
    Messages:
    561
    Likes Received:
    726
    Occupation:
    Freelancer
    Location:
    Estonia
    Home Page:
    I don't get it well you can integrate php to html or html to php so let's say that your website has tags like
    HTML:
    <option value="28" class="fjdpth1" ></option>
    

    So in php it will become

    PHP:

    echo '<option value="28" class="fjdpth1" ></option> ';

    So the main difference between php and html is that html is for the look of your website.
    But with php you can create some great functionality for it.
    You actually cant turn html to php you can only change the way how it will be outputted.
     
  3. welshman

    welshman Power Member

    Joined:
    May 9, 2009
    Messages:
    701
    Likes Received:
    190
    Ok. So if I wanted to add a script that was actually designed for a php file, do I have any chance?
     
  4. viracide

    viracide Registered Member

    Joined:
    Oct 12, 2008
    Messages:
    66
    Likes Received:
    14
    If you wanted to add a PHP script into a HTML, you would just rename the .html to .php and paste the script in where you want it.

    Edit: If you need a hand with anything, I can help. (For free)
     
    Last edited: Feb 26, 2010
  5. nbsweb

    nbsweb Junior Member

    Joined:
    Jan 5, 2009
    Messages:
    169
    Likes Received:
    74
    why don't you use joomla as a cms to make things easy for you?
     
  6. kaidoristm

    kaidoristm Power Member

    Joined:
    Feb 13, 2009
    Messages:
    561
    Likes Received:
    726
    Occupation:
    Freelancer
    Location:
    Estonia
    Home Page:
    Not problem at all just add the php part within PHP brackets like this lets take an piece of html code and add some php to it

    HTML:
    <html>
    <head>
    </head>
    <body>
    
      <div id="content">  
    
    
    <?php
    
    $imcool = 'cool';
    
    if($imcool == 'cool')
    {
    echo 'You man your really cool';
    }
    
    ?>
    
        </div>
    
    </body>
    </html>
    
    
    That' it save your file with extension .php and your done
     
  7. welshman

    welshman Power Member

    Joined:
    May 9, 2009
    Messages:
    701
    Likes Received:
    190
    Thanks for all the info everyone. Now I'm going to look at a way to include the same script to 221 pages. lol.
     
  8. viracide

    viracide Registered Member

    Joined:
    Oct 12, 2008
    Messages:
    66
    Likes Received:
    14
    If you have Dreamweaver there is a feature called Find and Replace in files. You can parse for a similar part in all the 221 pages and replace it with the PHP.

    eg:
    Find: <title>
    Replace with: <title><?php echo $title;?>
     
  9. mappum

    mappum Registered Member

    Joined:
    Aug 8, 2009
    Messages:
    84
    Likes Received:
    11
    Location:
    At my computer... how else would I be on a forum?
    I hope you understand you cannot convert html to php. You can integrate php into your website, however. If you are not planning on changing the content at all with php, there is absolutely no point in using it. The point of it is to make dynamic webpages (not always the same content) by having the server decide what html to send to the user.
     
  10. bizminder

    bizminder Registered Member

    Joined:
    Mar 16, 2010
    Messages:
    68
    Likes Received:
    3
    all the HTML must be enclosed in php tags <? ?>.
     
  11. underplay

    underplay Newbie

    Joined:
    Jan 13, 2009
    Messages:
    27
    Likes Received:
    1
    If it was me I would program a little php script to parse the old data and input that into a database, then write a simple php backend to retrieve and display the information. If your interested I will code it for you, for a price.
     
  12. kaidoristm

    kaidoristm Power Member

    Joined:
    Feb 13, 2009
    Messages:
    561
    Likes Received:
    726
    Occupation:
    Freelancer
    Location:
    Estonia
    Home Page:
    Little fix correct is <?php ?>
    Using like this <? ?> can cause bunch of errors.
     
  13. bizminder

    bizminder Registered Member

    Joined:
    Mar 16, 2010
    Messages:
    68
    Likes Received:
    3
    Hey thanks :)
     
  14. madblacker

    madblacker Regular Member

    Joined:
    Nov 2, 2009
    Messages:
    268
    Likes Received:
    19
    php is a server-side programming language, html is the presentation language for websites, you have to use html no matter what to present the page in the browser (usually with css, javascript, etc too)... its not possible to display php in a web browser in any meaningful way to an end user.. I guess you are trying to convert the structure of your site to php though but its probably best to get a php programmer at least to start with