flyingbuttressman
2nd August 2012 - 02:13 PM
QUOTE (Confused1+Aug 2 2012, 09:56 AM)
I think I have it:
It's a
heredoc or possibly a
nowdoc I need.
$str = <<<EOD
Example of string
spanning multiple lines
using heredoc syntax.
Oh, so you were trying to embed all that in a string? At that point I would probably put that html in a template file and pull it in with file_get_contents()
Confused1
2nd August 2012 - 05:21 PM
Thanks FBM, this does what I need:
< ? php
$instock = 1;
If ($instock > 0)
{
echo <<<EOT
This block of old HTML <br>
With links and pictures of bananas<br>
switched on <br>
by stock level > 0<br>
We have $instock bananas

<br>
EOT;
}
else
{
echo <<<EOT
And this new block of HTML <br>
switched on <br>
by stock level = 0 <br>
We have $instock bananas today

<br>
EOT;
}
? >
flyingbuttressman
2nd August 2012 - 06:01 PM
< ?php if($instock > 0): ? >
Some HTML about Bananas<br />
We have < ?php print $instock; ? > bananas
< ?php else: ? >
Some more html<br />
We have no bananas today
< ?php endif; ? >
Confused1
2nd August 2012 - 06:39 PM
@FBM,
Much better than my solution - many thanks.
-C2.
flyingbuttressman
2nd August 2012 - 08:56 PM
QUOTE (Confused1+Aug 2 2012, 02:39 PM)
@FBM,
Much better than my solution - many thanks.
-C2.
No problem. Are you just getting started with PHP?
Confused1
3rd August 2012 - 11:26 AM
This is my third website using PHP (since 2005). Mostly I'm just reusing chunks of code from earlier efforts so I'm getting worse and lazier instead of better. Most of my site is live from the stock database so it kind'a writes itself. The bit of code you provided will be used to switch on/off some of the fancier bits where I've provided pictures and details about the product. Thanks again, -C2.
Guest
28th August 2012 - 08:10 AM
Using "div" blocks, you can make your Web pages resize smoothly when site visitors resize their browser. Web developers refer to flexible Web page layouts as liquid layouts. Many pages on the Internet consist of columns laid out in tabular format. For instance, a navigation bar may appear on the left and the main content in the middle. An optional third column on the right may hold advertising or other information. Learning to use "div" blocks will help you design and create liquid pages that adjust to suit the needs of your site visitors.
PhysOrg scientific forums are totally dedicated to science, physics, and technology. Besides topical forums such as nanotechnology, quantum physics, silicon and III-V technology, applied physics, materials, space and others, you can also join our news and publications discussions. We also provide an off-topic forum category. If you need specific help on a scientific problem or have a question related to physics or technology, visit the PhysOrg Forums. Here you’ll find experts from various fields online every day.
To quit out of "lo-fi" mode and return to the regular forums, please click
here.