Welcome to WebmasterWorld Guest from 54.205.75.60

Forum Moderators: coopster & jatar k

Message Too Old, No Replies

PHP Template, dynamic pages question

Just a small question

   
12:15 am on Aug 7, 2004 (gmt 0)

10+ Year Member



Many of you know i've asked many questions. Now I have a few more ^.~

I have a content page, and a template page, ok. Now... I want to make one page for most of the dynamic aspects of my site (top sides and bottom portions and title). Questions on that...

How do I call it up, from the content page... or from the template? If the content page... where... and if the template.. where... (i.e. after the template is called, before the variables are called, etc).

Also how do you program HTML coding in php variables?
I know ' and " do two separate things.. but what does each do i forget -.-

Now if I have something like:

<td valign=top width="450">
<div align=center>
<table cellspacing=1 cellpadding=3 width="100%" bgColor=#000033 border=0>
<tr>
<td width="100%" bgColor=#000066><font color=#9FCDFF><center><b>News & Updates</b></center></font></TD></TR>
<tr>
<td width="100%" bgcolor=#F0F7FF>

can taht go into a variable like:

$code = "

--Code abover here all spaced out etc--

";

or would that cause a problem.

Thank you

11:44 am on Aug 7, 2004 (gmt 0)

10+ Year Member



$code = "
<p>
<b>this is some bold html</b>
</p>
"

That would cause a problem. The following is what you're looking for:

$code = <<<EOF
<p>
<b>this is some bold html</b>
</p>
EOF;

That wouldn't, and is probably what you're looking for!

3:03 pm on Aug 7, 2004 (gmt 0)

WebmasterWorld Administrator ergophobe is a WebmasterWorld Top Contributor of All Time 10+ Year Member Top Contributors Of The Month




That would cause a problem.

Only because it's missing a semicolon. Otherwise it will work just fine and be *much* faster [webmasterworld.com] than using the heredoc syntax.

Easier and marginally faster still is to use

$code = '
<p class="important">This is important text</p>
';

because you don't have to escape the quote marks around attributes as you would with

$code = "
<p class=\"important\">This is important text</p>
";

3:12 pm on Aug 7, 2004 (gmt 0)

WebmasterWorld Administrator ergophobe is a WebmasterWorld Top Contributor of All Time 10+ Year Member Top Contributors Of The Month




I know ' and " do two separate things

They do the same thing differently. Both delimit string literals, but " allows variable substition, new lines and so on, whereas ' has no substitution and only lets you escape ' So these are equivalent

echo "\nthis is a string on two \n but \\not three lines with a $variable_word in it and an errant \\ in front of the word 'not'";

echo "\nthis is a string on two \n but \\not three lines with a " . $variable_word . " in it and an errant \\ in front of the word 'not'\n";

echo 'this is a string on two' . "\n" . 'but \not three lines with a ' . $variable_word . ' in it and an errant \\ in front of the word \'not\'';

1:05 am on Aug 8, 2004 (gmt 0)

10+ Year Member



ergophobe I understood ur first post, not the second lol.

I get how ' doesn't need to escape " which is nice. I need to use that haha. But the second post i had no idea what u were saying.

And EOF... is that worse then just doing ergophobe's first post?

1:40 am on Aug 8, 2004 (gmt 0)

WebmasterWorld Administrator ergophobe is a WebmasterWorld Top Contributor of All Time 10+ Year Member Top Contributors Of The Month



EOF - that's the heredoc syntax. Not better or worse, but if you look at the link I posted, you'll see it's one of the slowest ways to output strings (but one of the more convenient.

My second post is just demonstrating the difference between the way single and double quotes work. Look closely at the differences.

Tom

6:57 am on Aug 8, 2004 (gmt 0)

10+ Year Member



Ah i see a few things, mostly periods lol.

Anyway i noticed you had:

<p="Important"> is important an actual command?

Also i may start a new thread on this... but i have this problem.

First the background:

I have a page with variables (content). This calls up the template page that calls the variables.

ok easy enough but... i'm going to need to call up... a few more pages with variables. (making updates easier). I don't know how to do that though... I can call up a template page and have that call variables that exist on the page calling the template (if that makes sense) but i dont' know how to take a few variables out of a page.

Do you konw how i'd do taht, and where the code to call up the variables and page would go? if u need the code i'll show u.

5:58 pm on Aug 8, 2004 (gmt 0)

WebmasterWorld Administrator ergophobe is a WebmasterWorld Top Contributor of All Time 10+ Year Member Top Contributors Of The Month



<p class=\"important\">

It's CSS and usually proferable to tags w/o semantic meaning like <b>