By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
455,746 Members | 1,849 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 455,746 IT Pros & Developers. It's quick & easy.

Assigning huge chunk of text to variable

P: n/a
Hi there!

I am making a web page, and I want the user to be able to decide which part of
the webpage ends up where, left or right side. So we have what I call "content"
and "sidebar". As in a text, you see the content to the left and the sidebar to
the right. This is done with something like this:

<table>
<tr>
<td>
## lots of php and html code to show the text and such
</td>
<td>
## lots of php and html code to contruct the sidebar ?>
</td>
</tr>
</table>

.... in a simplified manner. Now, the first chunk of php code is of course the
"content" and the second is the "sidebar".

Now, both the content and the sidebar consists of pure html and breaks into php
code, so it's not just php code. What I would like to do is read the two
different chunks of code into two seperate variable, much like, in pseudocode:

<? $content = "?>
<td>
## lots of php and html code to show the text and such
</td>
<? "; ?>

<? $sidebar = "?>
<td>
## lots of php and html code to contruct the sidebar ?>
</td>
<? "; ?>
And then just do a:

<table>
<tr>
$content
$sidebar
</tr>
</table>

Or reversed, depending on how the user wants to view it. It's fairly important
to me that I don't have to output all html via php (i.e. <? print "<font
size...>"; ?>)

Is there a way to do this with vanilla PHP ?

--
Sandman[.net]
Jul 17 '05 #1
Share this Question
Share on Google+
5 Replies


P: n/a
Sandman wrote:
Hi there!

I am making a web page, and I want the user to be able to decide which part of
the webpage ends up where, left or right side. So we have what I call "content"
and "sidebar". As in a text, you see the content to the left and the sidebar to
the right. This is done with something like this:

<table>
<tr>
<td>
## lots of php and html code to show the text and such
</td>
<td>
## lots of php and html code to contruct the sidebar ?>
</td>
</tr>
</table>

... in a simplified manner. Now, the first chunk of php code is of course the
"content" and the second is the "sidebar".

Now, both the content and the sidebar consists of pure html and breaks into php
code, so it's not just php code. What I would like to do is read the two
different chunks of code into two seperate variable, much like, in pseudocode:

<? $content = "?>
<td>
## lots of php and html code to show the text and such
</td>
<? "; ?>

<? $sidebar = "?>
<td>
## lots of php and html code to contruct the sidebar ?>
</td>
<? "; ?>
And then just do a:

<table>
<tr>
$content
$sidebar
</tr>
</table>

Or reversed, depending on how the user wants to view it. It's fairly important
to me that I don't have to output all html via php (i.e. <? print "<font
size...>"; ?>)

Is there a way to do this with vanilla PHP ?

$content =<<<EOT
Lots of things
EOT;
$sidebar =<<<EOT
Some more
EOT;

then eval() the variables to have it parse out the php code.

--
John Downey
http://delusive.dyn.ee
http://sage.dev.box.sk
http://blacksun.box.sk

Jul 17 '05 #2

P: n/a
I noticed that Message-ID: <mr**********************@news.fu-berlin.de>
from Sandman contained the following:
Is there a way to do this with vanilla PHP ?


Lots of ways. :-)

If you do the formatting with a stylesheet, you can simply use PHP to
load a different stylesheet. Use sessions and that stylesheet can be
used for all subsequent pages

--
Geoff Berrow
It's only Usenet, no one dies.
My opinions, not the committee's, mine.
Simple RFDs http://www.ckdog.co.uk/rfdmaker/
Jul 17 '05 #3

P: n/a
Sandman <mr@sandman.net> wrote:
I am making a web page, and I want the user to be able to decide which
part of the webpage ends up where, left or right side. So we have what I

[snip]

Another solution is to store content and sidebar in separate file and then
include them approriately:

<?php
// decide here what comes first, if(..) blablah
$first = "content.php";
$second = "sidebar.php";
?>
<table>
<tr>
<td>
<?php include($first); ?>
</td>
<td>
<?php include($second); ?>
</td>
</tr>
</table>

HTH;
JOn
Jul 17 '05 #4

P: n/a
In article <bn************@ID-175424.news.uni-berlin.de>,
Jon Kraft <jo*@jonux.co.uk> wrote:
Sandman <mr@sandman.net> wrote:
I am making a web page, and I want the user to be able to decide which
part of the webpage ends up where, left or right side. So we have what I

[snip]

Another solution is to store content and sidebar in separate file and then
include them approriately:

<?php
// decide here what comes first, if(..) blablah
$first = "content.php";
$second = "sidebar.php";
?>
<table>
<tr>
<td>
<?php include($first); ?>
</td>
<td>
<?php include($second); ?>
</td>
</tr>
</table>


Yes, I am aware of that, but I would rather have a more flexible solution,
where I could implement this without calling for external files. But thanks
anyway!

--
Sandman[.net]
Jul 17 '05 #5

P: n/a
In article <ti***********************@twister.neo.rr.com>,
John Downey <bl**@doesntexist.com> wrote:
Or reversed, depending on how the user wants to view it. It's fairly
important
to me that I don't have to output all html via php (i.e. <? print "<font
size...>"; ?>)

Is there a way to do this with vanilla PHP ?

$content =<<<EOT
Lots of things
EOT;
$sidebar =<<<EOT
Some more
EOT;

then eval() the variables to have it parse out the php code.

Yeah, that would have been great, but I am getting lots of errors when I do
that since the "Lots of things" contain both HTML and php code intervened.

This is the error I recieved:

Parse error: parse error, unexpected T_ENCAPSED_AND_WHITESPACE, expecting
T_STRING or T_VARIABLE or T_NUM_STRING in /atlas/virtuals/texter/list.php on
line 85

And line 85 was a regular php code in that text:

} elseif (! $r["kind"]){

which seemed to mess things up.

Perhaps my best bet is to keep it in seperate files.

--
Sandman[.net]
Jul 17 '05 #6

This discussion thread is closed

Replies have been disabled for this discussion.