homepage Welcome to WebmasterWorld Guest from 54.198.148.191
register, free tools, login, search, subscribe, help, library, announcements, recent posts, open posts,
Pubcon Website
Home / Forums Index / Code, Content, and Presentation / PHP Server Side Scripting
Forum Library, Charter, Moderators: coopster & jatar k

PHP Server Side Scripting Forum

    
PHP Template, dynamic pages question
Just a small question
Echo_Tyme




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

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

 

Warboss Alex




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

$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!

ergophobe




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


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>
";

ergophobe




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


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\'';

Echo_Tyme




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

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?

ergophobe




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

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

Echo_Tyme




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

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.

ergophobe




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

<p class=\"important\">

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

Global Options:
 top home search open messages active posts  
 

Home / Forums Index / Code, Content, and Presentation / PHP Server Side Scripting
rss feed

All trademarks and copyrights held by respective owners. Member comments are owned by the poster.
Terms of Service ¦ Privacy Policy ¦ Report Problem ¦ About
© Webmaster World 1996-2014 all rights reserved