473,383 Members | 1,846 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,383 software developers and data experts.

Trying to use a here doc within a switch


I'm trying to use here docs within a switch to output html. The code
below works (i.e. prints a Foo1 headline below my tab graphic) but if I
take out the comments and use the entire switch statement I get a parse
error. I've tried to simplify it down to the bones but can't get it much
simpler than this...

Can anybody spot my error?

thx,

wmc.

<?php

echo '<img border="0" src="images/tab' . $qstring . '.gif" width="570"
height="40" alt="" usemap="#mapTabs" />';
echo "\n<map name=\"mapTabs\">";

switch($qstring) {

case '1':

$content1 = <<< END1
<h1>Foo 1</h1>
END1;
echo $content1;
break;

/*
case '2':

$content2 = <<< END2
<h1>Foo 2</h1>
END2;
echo $content2;
break;

case '3':

$content3 = <<< END3
<h1>Foo 3</h1>
END3;
echo $content3;
break;
*/
}
?>
Jul 16 '05 #1
3 2356
On Tue, 26 Aug 2003 15:46:01 GMT in
<message-id:3F***************@williamc.com>
william c <te************@williamc.com> wrote:
I'm trying to use here docs within a switch to output html. The code
below works (i.e. prints a Foo1 headline below my tab graphic) but if
I take out the comments and use the entire switch statement I get a
parse error. I've tried to simplify it down to the bones but can't
get it much simpler than this...

Can anybody spot my error?

thx,

wmc.
[ snip ]

$content1 = <<< END1 ^
^

Can't have a space here =)

<h1>Foo 1</h1>
END1;
echo $content1;
break;

[ snip "repetitive of thew above ]
The same goes for the rest in the code.
HTH.

Regards,

Ian

--
Ian.H [Design & Development]
digiServ Network - Web solutions
www.digiserv.net | irc.digiserv.net | forum.digiserv.net
Programming, Web design, development & hosting.
Jul 16 '05 #2
$content1 = <<< END1

^
^

Can't have a space here =)

???

You mean can't have a space here, no?

END1;
^

The books I'm looking at say you *must* have a space after the <<< and
before the identifier.

--wmc.
Jul 16 '05 #3
On Tue, 26 Aug 2003 19:14:06 GMT in
<message-id:3F**************@williamc.com>
william c <te************@williamc.com> wrote:
$content1 = <<< END1 ^
^

Can't have a space here =)

???

Hmm.. my apologies for the confusion here William.. I've always used
heredocs with no space there (<<<EOF etc) but I've just tested and it
appears you can have a space, or without.. no difference =)


You mean can't have a space here, no?

END1;
^

The books I'm looking at say you *must* have a space after the <<< and
before the identifier.

--wmc.

There (' END1;') can't have a space before it, as this produces a 'Parse
error' (aka: syntax error).

Apologies for any confusion caused regarding the '<<< END1' part =)

Regards,

Ian

--
Ian.H [Design & Development]
digiServ Network - Web solutions
www.digiserv.net | irc.digiserv.net | forum.digiserv.net
Programming, Web design, development & hosting.
Jul 16 '05 #4

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

Similar topics

5
by: The Beast | last post by:
I'm trying to create a thread to write to the serial port and I keep getting an odd error cannot convert parameter 3 from 'unsigned long (void *)' to 'unsigned long (__stdcall *)(void *)' and...
2
by: Neo Geshel | last post by:
After pouring over about a dozen sites that clearly dealt with ClientID all by itself, I came to the realization that about 2/3+ of them were doing it wrong. It is indeed impossible to grab the...
3
by: Jerad Rose | last post by:
This is regarding Visual Studio 2003 (framework 1.1). We have several projects/libraries. Of course, many of these reference each other. If we only had one solution, we would simply add all of...
7
by: cytec123187 | last post by:
Hello, I am working on an Adobe Acrobat file that uses javascript for calculations. I am trying to create a field that uses two other fields to determine a number value. I think this requires...
5
by: Learner | last post by:
Hello, Here is the code snippet I got strucked at. I am unable to convert the below line of code to its equavalent vb.net code. could some one please help me with this? static public...
2
by: rich | last post by:
I am working on a page with a right column that I want to use for navigation. In this right column I am using the below code to set a value for the link. I am using the variable $test right now....
3
by: jimbo24 | last post by:
Hello, I have inherited a large piece of C code which was written in a non ansi compliant compiler. This compiler allowed variable declaration anywhere within a function body, whereas the...
3
by: tshad | last post by:
I have dataGrid that I am filling from a List Collection and need to sort it by the various columns. So I need to be able to sort the Collection and found that you have to set up your own...
7
by: jeddiki | last post by:
Hi, As I am in Turkey at present, I can not see vidoes on youtube. So I have tried a few proxies but keep finding them slow or not working. So I have installed myphpProxy on my server under...
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...
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...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

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.