xhtml strict is being very stict why?

C

Christopher R

Just beginning php.Why is xhtml validator saying, "end of line reached
before closing quote. Quoted strings can not span lines.?"


<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<meta http-equiv="content-type" content="text/html; charset=iso-8859-1" />
<title>Form Feedback</title>
</head>
<body>
<?php
# Script 2.2 - handle_form.php Tip Extension! Not in the book!
// $login substituted for $name
// relates to form.html
// breaks between the lines causes a parse error


echo "$login<p> Your email address is $email</p>";

echo "<p>$password</p>";
// end of line reached before closing quote. Quoted strings can not span
lines.
?>
</body>
</html>
 
D

DU

Christopher said:
Just beginning php.Why is xhtml validator saying, "end of line reached
before closing quote. Quoted strings can not span lines.?"


<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<meta http-equiv="content-type" content="text/html; charset=iso-8859-1" />
<title>Form Feedback</title>
</head>
<body>
<?php
# Script 2.2 - handle_form.php Tip Extension! Not in the book!
// $login substituted for $name
// relates to form.html
// breaks between the lines causes a parse error


echo "$login<p> Your email address is $email</p>";

I'm pretty sure you need to escape the forward slashes like this:

echo "$login said:
echo "<p>$password</p>";

here too:
echo "<p>$password<\/p>";

otherwise we would need an url to further verify your file.
// end of line reached before closing quote. Quoted strings can not span
lines.
?>
</body>
</html>

DU
--
Javascript and Browser bugs:
http://www10.brinkster.com/doctorunclear/
- Resources, help and tips for Netscape 7.x users and Composer
- Interactive demos on Popup windows, music (audio/midi) in Netscape 7.x
http://www10.brinkster.com/doctorunclear/Netscape7/Netscape7Section.html
 
A

Adrienne

Just beginning php.Why is xhtml validator saying, "end of line reached
before closing quote. Quoted strings can not span lines.?"


<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> <html
xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en"> <head>
<meta http-equiv="content-type" content="text/html; charset=iso-8859-1"
/> <title>Form Feedback</title> </head> <body> <?php
# Script 2.2 - handle_form.php Tip Extension! Not in the book!
// $login substituted for $name
// relates to form.html
// breaks between the lines causes a parse error


echo "$login<p> Your email address is $email</p>";

echo "<p>$password</p>";
// end of line reached before closing quote. Quoted strings can not
span lines.
?>
</body>
</html>

Are you validating the code, or the XHTML that was generated by the code?
You need to validate the XHTML the PHP is generating, not the PHP code (of
course the PHP needs to be valid to generate the XHTML correctly).
 
C

Christopher R

Adrienne said:
Are you validating the code, or the XHTML that was generated by the code?
You need to validate the XHTML the PHP is generating, not the PHP code (of
course the PHP needs to be valid to generate the XHTML correctly).
I'm validating the posted code here using homesite's validator. The message
returned is, end of line reached before closing quote. Quoted strings can
not
span lines. End of message. I need to put a semi-colon after the quote. I
even tried to put the quote at the end of the line but no luck. If I
understand your question correctly, I am validating the code. It works fine
but just gives me a validation error. Why?
Thanks in advance.
 
C

Christopher R

<!--This kind of quote works inside the php tag -->

//but this sort gives me an error.

It is working now.
 
H

Hywel Jenkins

Christopher R said:
I'm validating the posted code here using homesite's validator. The message
returned is, end of line reached before closing quote. Quoted strings can
not
span lines. End of message. I need to put a semi-colon after the quote. I
even tried to put the quote at the end of the line but no luck. If I
understand your question correctly, I am validating the code. It works fine
but just gives me a validation error. Why?
Thanks in advance.

So you're trying to validate unparsed PHP code using an HTML
validator. Did you really expect that to work? How about trying to
translate Italian to English using Babelfish's French to English
translation engine?
 
S

SteW

Hywel said:
So you're trying to validate unparsed PHP code using an HTML
validator. Did you really expect that to work? How about trying to
translate Italian to English using Babelfish's French to English
translation engine?

It can work, though it takes more effort to get readable code and there
are difficulties if you want an <?xml> line with sessions - both want to
be first. But you know the script will always produce valid html.

Paste this into a new file, save locally as test.php then use file
upload (i.e unparsed php) at http://validator.w3.org/ :

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>php test</title>
<meta http-equiv="Content-Type" content="text/html;
charset=iso-8859-1" />
</head>
<body>
<h1>Can a php page validate?</h1>
<?php $validates = true; ?>
<p>
<?php if($validates){
$answer = "Yes it can.";
}else{
$answer = "No it can't.";
}
echo $answer;
?>
</p>
</body>
</html>
 
L

Leif K-Brooks

Christopher R said:
It works fine but just gives me a validation error. Why?

The browser sees the XHTML result of the code, but you're giving the
validator the PHP code itself.
 
S

StealthMonkey

Homesite's Validate isn't designed to validate PHP. I know that I used
to use Homesite and its validator all the time when I used HTML 4, but
now that I use XHTML inside of PHP, I don't even bother with the
validator anymore. If you want a good validator, check out
validator.w3.org. It will check for valid HTML after the PHP engine
has parsed the code, not before like Homesite attempts to do.
 
J

Jukka K. Korpela

SteW said:
But you know the script will always produce valid html.

Huh? Why validate then? Or so you mean that a validator report of PHP
code would somehow mean that the HTML documents are valid?
Paste this into a new file, save locally as test.php then use file
upload (i.e unparsed php) at http://validator.w3.org/ :

That wouldn't mean much, since a validator treats <?php ...?> as
processing instructions and effectively ignores them.
 
S

SteW

Jukka said:
Huh? Why validate then? Or so you mean that a validator report of PHP
code would somehow mean that the HTML documents are valid?


That wouldn't mean much, since a validator treats <?php ...?> as
processing instructions and effectively ignores them.

The php script engine will test the syntax of the php. Let's use the
validator to detect syntax errors in html markup.

This style uses php to generate the content only:
<p>
<?php
if ($a){
echo " this ";
}else{
echo " that ";
}
?>
</p>

The validator need only be used once as the html does not change, no
matter which condition is met.

This style uses php to generate both the content and the markup:
<?php
if ($a){
echo "<p> this </p>";
}else{
echo "<p that </p>"
}
?>

The validator can now only be used to check the _output_ of the php
script. In this example there are two possible pages to check. One of
the pages will have incorrect syntax.
With n such constructs the output of 2^n possibilities must be checked.

Ste W
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,756
Messages
2,569,535
Members
45,008
Latest member
obedient dusk

Latest Threads

Top