473,327 Members | 2,071 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,327 software developers and data experts.

can you use html as value for php variable

Is there a way to use html as a value for a php variable while going
in and out of the php tag?

For example, can you do something like this?

<?php $strHtml = ?>
<p>somehtml here</p>
<?php ; ?>

so that the value of $strHtml equals "<p>somehtml here</p>"

Apr 26 '07 #1
4 1466

"KidBrax" <br***********@gmail.comwrote in message
news:11**********************@u32g2000prd.googlegr oups.com...
Is there a way to use html as a value for a php variable while going
in and out of the php tag?

For example, can you do something like this?

<?php $strHtml = ?>
<p>somehtml here</p>
<?php ; ?>

so that the value of $strHtml equals "<p>somehtml here</p>"
<?php
$strHtml = "<p>somehtml here<p>";
?>
Don't forget to end the line with a semicolon.
HTH
Vince
Apr 26 '07 #2
Rik
KidBrax wrote:
Is there a way to use html as a value for a php variable while going
in and out of the php tag?

For example, can you do something like this?

<?php $strHtml = ?>
<p>somehtml here</p>
<?php ; ?>

so that the value of $strHtml equals "<p>somehtml here</p>"
AFAIK, no. Which a simple test would show.
Heredoc saves a lot of escaping quotes though, if that's your problem:
$strHTML = <<<HTML
<p>someHtml here, where we dont have to worry about escaping ' and ", so
that'll just go fine. Hell, we can even use variables:
{$_SERVER['HTTP_HOST']}. The only thing that should be escaped here is
are valid variable names, so $names should be \$names.
HTML;
--
Rik Wasmus

Estimated date being able to walk again: 01-05-2007.
Less then a week, hurray!
Apr 26 '07 #3
"Vince Morgan" <vi****@REMOVEoptusnet.com.auwrote in message
news:46***********************@news.optusnet.com.a u...
>
"KidBrax" <br***********@gmail.comwrote in message
news:11**********************@u32g2000prd.googlegr oups.com...
Is there a way to use html as a value for a php variable while going
in and out of the php tag?

For example, can you do something like this?

<?php $strHtml = ?>
<p>somehtml here</p>
<?php ; ?>

so that the value of $strHtml equals "<p>somehtml here</p>"

<?php
$strHtml = "<p>somehtml here<p>";
?>
Don't forget to end the line with a semicolon.
Or close your tags </plike I just did ;)
HTH
Vince


Apr 26 '07 #4
KidBrax kirjoitti:
Is there a way to use html as a value for a php variable while going
in and out of the php tag?

For example, can you do something like this?

<?php $strHtml = ?>
<p>somehtml here</p>
<?php ; ?>

so that the value of $strHtml equals "<p>somehtml here</p>"
<?php ob_start(); ?>
<p>some html here</p>
<?php $strHtml = ob_get_clean(); ?>

--
Ra*********@gmail.com

"Wikipedia on vähän niinq internetin raamattu, kukaan ei pohjimmiltaan
usko siihen ja kukaan ei tiedä mikä pitää paikkansa." -- z00ze
Apr 26 '07 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
by: asim | last post by:
Hi All i m transforming a simple XSL file on Server side using MSXML Parser ... and writting resultant HTML directly on browser .. is there any way to get this HTML in a variable ??? i seen the...
3
by: Sandros | last post by:
Background: I'm collecting usability statistics for a group of applications. Each count has the following attributes: date, application, major heading, minor heading, count. My intent is to pull...
4
by: VK | last post by:
09/30/03 Phil Powell posted his "Radio buttons do not appear checked" question. This question led to a long discussion about the naming rules applying to variables, objects, methods and properties...
3
by: aaa | last post by:
I fail to see the connection between the code behind and the raw HTML of the ASPX page how do you get variables and functions to communicate with each other? I cannot get this to even fire:...
2
by: simon | last post by:
hello, what i'm looking to do is store the path of the app on a the server for reuse in the site. my thoughts so far are... -make a key in the web.config file -retrieve the value in globals.asax...
11
by: saurabh | last post by:
Can anybody tell me how to change the value of an html control from the c#.... eg i hv one asp.net radio button control and one html hidden variable... so on page load in case the radio button is...
2
by: ksr | last post by:
Hello, I have a HTML page, which loads an activeX control in the browser. In the <HEADsection, I have javascript similar to the following, <SCRIPT language="JavaScript"> var Index = ""; //...
3
daJunkCollector
by: daJunkCollector | last post by:
I have the html/javascript posted below, I imagine the fix to my problem is something simple that I am overlooking. My script is a little bit of html and javascript, and there is an embedded flash...
10
by: mike4722 | last post by:
I wish to have the form to be able to automatically select the radio button based on the logic of HTML/php variable. example show below: javascript: function autoForm(value) { var myForm =...
1
by: arggg | last post by:
I have an external html that is a form. the Values of the form elements have <?= $results ?> type information however with file_get_contents in the main php file that then stores the contents to a...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.