PDA

View Full Version : Can i use a switch for ' ; '


joop
12-11-2004, 08:16 PM
Im trying to use a php class member function to output data to my screen but it doesn't accept the ' ; ' all the time (though this really is not on every occation).

Heres a pice of the relavent code.


$homepage->SetContent("<table width='100%' border='0' cellpadding='2' cellspacing='3'>
<tr>
<td width='100%' scope='col' valign='top' align='left'>
Let us begin with the simple framework required to successfully build a web page.<br><br>
<table align='center' border='1' class='sourceblue' >
<tr><td>
<blockquote><html>
<p><head><br>
<title ><font color="#000000">My First Web Page</font></title><br>
</head ></p>
<p><body ><br>
</body ></p>
<p></html >
</p></blockquote></td></tr></table>


i recieve the error : Parse error: parse error, unexpected ';' in /home/sites/inciter.org.uk/public_html/html/html_firstpage.php on line 24

Do i need to use a switch to resolve this problem like the new line switch ' \n ' ?

Zykaz
12-11-2004, 08:37 PM
Honestly, I'm not quite sure what you mean. Would you mind clarifying a bit?

But, one thing I did notice, is that inside SetContent(), you have the line:
<title ><font color="#000000">My First Web

Which could be a possible problem. Using double quotes (") while setting the font color _may_ terminate the start of SetContent(). Try changing them to single quotes ('), and let me know exactly what you mean.

joop
12-12-2004, 02:12 AM
Hello again :-)

Sorry about that, well spotted and yes that solved the problem :oops:

um... but for future reference, in my member function when used i type :

myfunction(" fill it with all kinds of data ");

Well if i was to try and demonstrate how to use one of my software components, i sometimes need to output features that will end in "); and im assuming that php might think that it's reached the end of it's own funtion.

Do you know of anyway to stop this from happening? The logic to formatting this kinda string is a little above me, how an earth would you override a critical php feature?... lol Thanks for your help :D

Zykaz
12-12-2004, 09:00 PM
I've never tried that in PHP, but I have a few suggestions that I think will work.

1. In Perl (Perl behaves a lot like PHP most of the time), it handles this by using a backslash ( \ ) to enter _just_ the character. Say, for example, I want to put a quote inside of a print command in a Perl program, I would:
print "This is a quote: \"Pleasure in the job puts perfection in the work.\" -Aristotle.";

2. Use the ASCII equivalent. Like you did for the < and > in your script.

3. Put it in a variable.

joop
12-14-2004, 07:49 PM
Thank you i will try those ideas in a couple of days - i think your probably right. Hopfully a variable will succeed :-)