The Shed is going Social! Join us on FaceBook and Twitter and chime in on the conversation.
|
 |
|
Dev Shed Forums
> Web Site Management
> Scripts
|
html2php
Discuss html2php in the Scripts forum on Dev Shed. html2php Scripts forum discussing topics including building, optimization, and implementation. Discuss which scripting language is best suited to your needs.
|
|
 |
|
|
|
|

Dev Shed Forums Sponsor:
|
|
|

September 24th, 2003, 08:52 PM
|
 |
webber
|
|
Join Date: Oct 2000
Location: San Juan - Argentina
Posts: 594
Time spent in forums: 2 Days 10 h 25 m 20 sec
Reputation Power: 13
|
|
html2php
__________________
Enrique Becerra
CodeIgniter, Joomla & Java Development
www.itexa.com.ar
|

September 24th, 2003, 08:54 PM
|
 |
Moderator Emeritus
|
|
Join Date: Feb 2002
Location: Scottsdale, AZ
|
|
|
Moved to the Scripts forum from PHP.
|

September 25th, 2003, 12:37 AM
|
 |
Banned ;)
|
|
Join Date: Nov 2001
Location: Woodland Hills, Los Angeles County, California, USA
|
|
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! 
__________________
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
Last edited by Scorpions4ever : September 25th, 2003 at 12:39 AM.
|

October 2nd, 2003, 12:56 PM
|
 |
webber
|
|
Join Date: Oct 2000
Location: San Juan - Argentina
Posts: 594
Time spent in forums: 2 Days 10 h 25 m 20 sec
Reputation Power: 13
|
|
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
|

October 3rd, 2003, 06:56 PM
|
 |
Banned ;)
|
|
Join Date: Nov 2001
Location: Woodland Hills, Los Angeles County, California, USA
|
|
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.
|

October 3rd, 2003, 07:17 PM
|
 |
webber
|
|
Join Date: Oct 2000
Location: San Juan - Argentina
Posts: 594
Time spent in forums: 2 Days 10 h 25 m 20 sec
Reputation Power: 13
|
|
|
hey man...
what do u do to be SO quick & efficient?
incredible, awesome, and im very thankful 2 ya
great! still astonished...
|
Developer Shed Advertisers and Affiliates
| Thread Tools |
Search this Thread |
|
|
|
| Display Modes |
Rate This Thread |
Linear Mode
|
|
Posting Rules
|
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
HTML code is Off
|
|
|
|
|