Thread: html2php

    #1
  1. webber
    Devshed Novice (500 - 999 posts)

    Join Date
    Oct 2000
    Location
    San Juan - Argentina
    Posts
    594
    Rep Power
    14

    Unhappy html2php


    hi ppl
    i'm in urgent need of an util like this...
    i gotta transform lot of HTML designs to
    print '.....';
    and i'll become mad if i do it line per line...

    i saw this one, it is perfect, but its author doesnt want 2 give it
    http://quasarcr.com/html2php/

    this one is nice too
    http://www.html2php.com/frahtm2php.html

    and this seems 2 work not so good
    http://www.linuxlogin.com/tools/html2php.php

    i got the perl script from hostscripts.com but dont have perl and wont install it 4 this...

    plz... does some1 have some of these nice scripts?

    thanks...
    A LOT
    Enrique Becerra
    CodeIgniter, Joomla & Java Development
    www.itexa.com.ar
  2. #2
  3. Moderator Emeritus
    Devshed Supreme Being (6500+ posts)

    Join Date
    Feb 2002
    Location
    Austin, TX
    Posts
    7,183
    Rep Power
    2220
    Moved to the Scripts forum from PHP.
    DrGroove, Devshed Moderator | New to Devshed? Read the User Guide | Connect with me on LinkedIn
  4. #3
  5. Banned ;)
    Devshed Supreme Being (6500+ posts)

    Join Date
    Nov 2001
    Location
    Woodland Hills, Los Angeles County, California, USA
    Posts
    9,593
    Rep Power
    4207
    Erm, can't you just do something like this (necessary PHP code inserted in bold text over the HTML)
    Code:
    <?
    print <<<END_OF_HTML
    <html>
      <head>
        <title>Hello World</title>
      </head>
      <body>
        <h1>Hello World!</h1>
        Pick up your balls and load up your cannon<br>
        For a 21 gun salute<br>
        <i>For Those About To Rock (We Salute You)</i>
      </body>
    </html>
    
    END_OF_HTML;
    ?>
    As you can see, it works over multiple lines and thus you don't have to insert a print '...'; on each line of HTML. Also, you can put PHP variables in the middle and it'll interpolate them just fine. So, with this approach, all you have to do is insert the bold text at the top and bottom of any HTML file and voila!
    Last edited by Scorpions4ever; September 25th, 2003 at 12:39 AM.
    Up the Irons
    What Would Jimi Do? Smash amps. Burn guitar. Take the groupies home.
    "Death Before Dishonour, my Friends!!" - Bruce D ickinson, Iron Maiden Aug 20, 2005 @ OzzFest
    Down with Sharon Osbourne

    "I wouldn't hire a butcher to fix my car. I also wouldn't hire a marketing firm to build my website." - Nilpo
  6. #4
  7. webber
    Devshed Novice (500 - 999 posts)

    Join Date
    Oct 2000
    Location
    San Juan - Argentina
    Posts
    594
    Rep Power
    14
    it worked great scrorpions4ever, but plz let me ask u now another question. i use lot of sending mail with php, and i want to do following:

    $var = 'hello world!';

    $html = '
    <html>
    <head>
    <title>Hello World</title>
    </head>
    <body>
    <h1>Hello World!</h1>
    Pick up your balls and load up your cannon<br>
    For a 21 gun salute<br>
    <i>For Those About To Rock (We Salute You)</i>
    <br><br>$var
    </body>
    </html>
    ';

    but when i do

    echo 'this is the content<br>'.$html;

    I cannot see the $var's value...

    what da ya advice me to do in that case?
    itd be great i can make the html design with the vars & copy / paste like the 1st example u gave me... thanks
  8. #5
  9. Banned ;)
    Devshed Supreme Being (6500+ posts)

    Join Date
    Nov 2001
    Location
    Woodland Hills, Los Angeles County, California, USA
    Posts
    9,593
    Rep Power
    4207
    You should use double quotes(") instead of single quotes ' in this statment. i.e
    $html = "
    ...
    $var
    ";

    instead of what you have now
    $html = '
    ...
    $var
    ';

    Single quotes don't allow interpolated variables, i.e. they render the string as you see it. Double quotes allow interpolated variables, i.e. they replace all $ variables with the actual values.

    Better still, use <<<END_OF_HTML style coding instead. Why, you ask? - Well, if you had any double quotes in your html, you would have needed to escape them with a \ character. With the <<< style, you don't need to do that. The following code illustrates this:
    Code:
    <?
    $var = 'hello world!';
    
    $html = <<<END_OF_HTML
    <html>
      <head>
        <title>Hello World</title>
      </head>
    <body>
    <h1>Hello World!</h1>
    Pick up your balls and load up your cannon<br>
    For a 21 gun salute<br>
    <i>For Those About To Rock (We Salute You)</i><br>                            
    Isn't this a great "test"        
    <br><br>$var                                   
    </body>                               
    </html>                              
    END_OF_HTML;
                                                     
    echo 'This is the content2<br>'. $html;
    ?>
    Replace the END_OF_HTML code with single or double quotes and it won't work any more, since the HTML has " and ' within it (which you'll need to escape as \" and \\' to make them work). With END_OF_HTML style syntax, you don't have to escape them. BTW you don't have to call the tag as END_OF_HTML. You can use any string you like. Just remember the following simple rules:
    (a) The last END_OF_HTML should be on its own line with a ; at the end
    (b) The last END_OF_HTML; should have no leading or trailing spaces. That means no spaces after the ;
    (c) Match your tags. This means, if you do this
    $html = <<<FOO
    then your HTML code should end with a corresponding:
    FOO;

    [edit] Looks like the VB code doesn't render \\' correctly. You need to \\ it to work with ' and show up correctly on the forum[/edit]
    Last edited by Scorpions4ever; October 3rd, 2003 at 07:30 PM.
    Up the Irons
    What Would Jimi Do? Smash amps. Burn guitar. Take the groupies home.
    "Death Before Dishonour, my Friends!!" - Bruce D ickinson, Iron Maiden Aug 20, 2005 @ OzzFest
    Down with Sharon Osbourne

    "I wouldn't hire a butcher to fix my car. I also wouldn't hire a marketing firm to build my website." - Nilpo
  10. #6
  11. webber
    Devshed Novice (500 - 999 posts)

    Join Date
    Oct 2000
    Location
    San Juan - Argentina
    Posts
    594
    Rep Power
    14
    hey man...
    what do u do to be SO quick & efficient?
    incredible, awesome, and im very thankful 2 ya
    great! still astonished...

IMN logo majestic logo threadwatch logo seochat tools logo