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

Tool to validate HTML code with PHP tags?

Hi,

I have some php pages with a lot of HTML code.
I am looking for a HTML validator tool (like TIDY).
TIDY is not good enough with PHP tags (it removes a lot of php code).

Do you have any idea?

Thanks you very much

Rod

Apr 26 '07 #1
26 25527
*** webrod escribió/wrote (26 Apr 2007 09:04:36 -0700):
I have some php pages with a lot of HTML code.
I am looking for a HTML validator tool (like TIDY).
TIDY is not good enough with PHP tags (it removes a lot of php code).
PHP is *not* HTML so having problems with an HTML validator is exactly what
you could expect.

I presume you want to validate the HTML generated by your PHP script. Just
load your script through a web server and validate the output with the W3C
validators:

http://validator.w3.org

You have two options:

1) If your web is hosted in a public server, feed the validator with the
URL

2) If your web is hosted in a local test server, feed it with a file
upload. Use your browser's "Save as" feature and save it as plain HTML.

If you Google for "Webdeveloper toolbar" you'll find a Firefox extension
and an Internet Explorer toolbar; any of them can assist you in validating
your HTML.

--
-+ http://alvaro.es - Álvaro G. Vicario - Burgos, Spain
++ Mi sitio sobre programación web: http://bits.demogracia.com
+- Mi web de humor con rayos UVA: http://www.demogracia.com
--
Apr 26 '07 #2
webrod wrote:
Hi,

I have some php pages with a lot of HTML code.
I am looking for a HTML validator tool (like TIDY).
TIDY is not good enough with PHP tags (it removes a lot of php code).

Do you have any idea?

Thanks you very much

Rod
I see you've posted this message separately to several newsgroups, instead of
sending it to these newsgroups all at once.

Firstly, this is a needless effort on your part, and secondly, this means
responses will only show up on the newsgroup that the response was posted in.
Check alt.comp.lang.php for my answer to your question.

If you posted this with a News client, just add all the newsgroups you want to
post to in the recipients above, like you would do with an email to several
people. If you posted with Google Groups, you can enter several groups in the
"To Newsgroups" field, separated by commas. This'll save you a lot of work
otherwise wasted on posting to and checking to all these different groups
(a.c.p.l, c.p.l, a.p, etc.) :)

--
cb
Apr 26 '07 #3
oups! thanks you, I didn't know that.
I thought it was not possible.
Sorry about that.

I provide my answer here:

Hi,

I guess I was not clear enough.

I do not want to validate the output of a php page, I want to validate
the php page itself.
My php code NEVER provides HTML code. That's a very important rule I
follow.
I mean I never do that:
<?php echo "<a href='$myLink'>go to my link</a>" ?>
I do that:
<a href='<?php echo $myLink?>'>go to my link</a>

Actually I have the main php page which does the business (only PHP
code, no HTML at all), then I include a template with HTML code + a
little bit of php code.

I would like now to find a tool which is able to validate my XHTML
code (within the template) and udpate the XHTML to be conformed with
W3C rules.
For example it should automatically update <brto <br/>.
TIDY does this work. Unfortunatelly it doesn't like php tags and
remove a lot of them.

I would like to work on the templates and not on the output to do the
job automatically.
If I work on the output, I have to manually update all the templates!!
Unfortunatelly I have a lot of templates.

Do you have an idea?

thanks

rod

Apr 27 '07 #4
webrod wrote:
oups! thanks you, I didn't know that.
I thought it was not possible.
Sorry about that.

I provide my answer here:

Hi,

I guess I was not clear enough.

I do not want to validate the output of a php page, I want to validate
the php page itself.
My php code NEVER provides HTML code. That's a very important rule I
follow.
I mean I never do that:
<?php echo "<a href='$myLink'>go to my link</a>" ?>
I do that:
<a href='<?php echo $myLink?>'>go to my link</a>

Actually I have the main php page which does the business (only PHP
code, no HTML at all), then I include a template with HTML code + a
little bit of php code.

I would like now to find a tool which is able to validate my XHTML
code (within the template) and udpate the XHTML to be conformed with
W3C rules.
For example it should automatically update <brto <br/>.
TIDY does this work. Unfortunatelly it doesn't like php tags and
remove a lot of them.

I would like to work on the templates and not on the output to do the
job automatically.
If I work on the output, I have to manually update all the templates!!
Unfortunatelly I have a lot of templates.

Do you have an idea?

thanks

rod
Rod,

As Alvaro said - http://validator.w3.org.

How you generate the html (and yes, you are using PHP to generate HTML -
the link destination in the href is part of html) is unimportant. The
result is html.

--
==================
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
js*******@attglobal.net
==================
Apr 27 '07 #5
As Alvaro said -http://validator.w3.org.

No, this validates the output (ok you could provide the php file as an
input).
And as I said I would like the tool to do the modification itself.
Like the great TIDY tool (but it removes php code!!).
How you generate the html (and yes, you are using PHP to generate HTML -
the link destination in the href is part of html) is unimportant. The
result is html.
Of course the final result is HTML ;-)
If you consider the output, obviously this is HTML+CSS+Javascript
But if you consider the INPUT, there is 2 ways to build a php page.
How to say.... They are 2 families of developpers ;-)
The first family will ask PHP to generate the HTML code (HTML within
php tag)
The second family will insert PHP tag within HTML tag.
And believe me, this is not the same thing, even if, obviously, the
output is exactly the same HTML.
(I belong to the second family)

Any other idea to validate my templates files which contains PHP code
within HTML tags?

Rod

Apr 27 '07 #6
PHP is *not* HTML

of course!!
>so having problems with an HTML validator is exactly what
you could expect.
HTML validator means that the HTML will be validated in a page.
It does not mean that you can only validate a .html file.
The proof with TIDY. It is able to work with php tags (you even have
some option to deal with php).
Unfortunately, it does that badly. A lot of bugs.
So I am wondering if there is another tool like TIDy but without bugs.
I use the ZEND IDE but it does not validate HTML code.

I presume you want to validate the HTML generated by your PHP script.
Just load your script through a web server and validate the output with the W3C
validators:

http://validator.w3.org
I know this website, but unfortunatelly, it does not automatically
update the code (for example to update <brto <br/>)
And it works on the output, not on the input (except if you provide
the php file but I guess it doesn't like php code. It's not the goal
of this website to validate XHTML code in a php page)

Thanks for your help

Rod
Apr 27 '07 #7
webrod wrote:
>As Alvaro said -http://validator.w3.org.

No, this validates the output (ok you could provide the php file as an
input).
And as I said I would like the tool to do the modification itself.
Like the great TIDY tool (but it removes php code!!).
>How you generate the html (and yes, you are using PHP to generate HTML -
the link destination in the href is part of html) is unimportant. The
result is html.

Of course the final result is HTML ;-)
If you consider the output, obviously this is HTML+CSS+Javascript
But if you consider the INPUT, there is 2 ways to build a php page.
How to say.... They are 2 families of developpers ;-)
The first family will ask PHP to generate the HTML code (HTML within
php tag)
The second family will insert PHP tag within HTML tag.
And believe me, this is not the same thing, even if, obviously, the
output is exactly the same HTML.
(I belong to the second family)
No, there is no difference. In either case you are using PHP to output
information to the page. Nothing more, nothing less. Zip. Nada.

You are getting lost in the details. Look at the higher level.
Any other idea to validate my templates files which contains PHP code
within HTML tags?

Rod
So what exactly do you want to validate? The only important things are
- the PHP code itself is valid (the interpreter will tell you if it's
not), and the HTML output is valid (which the validator will tell you).

What exactly do you expect?

--
==================
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
js*******@attglobal.net
==================
Apr 27 '07 #8
No, there is no difference. In either case you are using PHP to output
information to the page. Nothing more, nothing less. Zip. Nada.
This is because you are focusing on the outpout. As I said, YES the
output is EXACTLY the same, if you compare the generated HTML, I agree
this is the same.
So what exactly do you want to validate? The only important things are
- the PHP code itself is valid (the interpreter will tell you if it's
not),
I don't care about the PHP code
>and the HTML output is valid (which the validator will tell you).
Yes. This is what I want.
BUT:
I don't want to validate the output because I am NOT looking for a
tool which only validate the HTML (like "you should replace <brby
<br/to be conformed with XHTML rule bla bla bla").
I am looking for a tool which will do the job for me ;-)
I want it to replace automatically <brby <br/in my php page.
I want it to udpate the code. (actually TIDY do it It works even with
PHP page but with bugs!!)

I'm sure you understand that I need to do this step on the input (the
php page) instead of the output (or its work will be lost!!!!!).

And then you get a better understanding of the difference between
familly 1 and familly 2.

Obviously, if you want to validate the output, there is no difference
(who said it is what I want?). But if you need to validate the HTML
code from a php page, you will understand it will be easier to
validate HTML code if the php code is in the HTML (and not the
opposite, when HTML is in the php code).
And that's why it is always recommended to belong to the second
family ;-)

Rod

Apr 27 '07 #9
webrod wrote:
I don't care about the PHP code
Neither does an HTML validator.

--
Toby A Inkster BSc (Hons) ARCS
http://tobyinkster.co.uk/
Geek of ~ HTML/SQL/Perl/PHP/Python*/Apache/Linux

* = I'm getting there!
Apr 27 '07 #10
You want something to 'fix' the HTML code for you, like Tidy does. I'd
like to say
that it's impossible, but of course, it isn't impossible *in theory*.

It's easy enough to say, use the w3c validator and fix the HTML
yourself!

The tool you want would have to interpret PHP and then 'validate' the
*output*
of your PHP script, and then somehow figure out where in the script
the
error came from... There are so many ways PHP can generate HTML, this
would require a HUGE amount of intelligence. It would have to figure
out
how and where the HTML came from.

The number of ways PHP (or any program) can generate HTML (or anything
else) is infinite.

No tool can be that smart.

I suppose it could be done if combined with some template based
programming
discipline, but it'd be easier to use the w3c validator to find the
errors, and your
knowledge of your script to figure out where that error came from.
Apr 27 '07 #11
webrod wrote:
>No, there is no difference. In either case you are using PHP to output
information to the page. Nothing more, nothing less. Zip. Nada.

This is because you are focusing on the outpout. As I said, YES the
output is EXACTLY the same, if you compare the generated HTML, I agree
this is the same.
Then who cares about how it's generated? I sure don't. You're fixating
on the details instead of the overall picture.
>So what exactly do you want to validate? The only important things are
- the PHP code itself is valid (the interpreter will tell you if it's
not),

I don't care about the PHP code
Then don't worry about validating the source. Just use the HTML
validator to check the output.
>and the HTML output is valid (which the validator will tell you).

Yes. This is what I want.
BUT:
I don't want to validate the output because I am NOT looking for a
tool which only validate the HTML (like "you should replace <brby
<br/to be conformed with XHTML rule bla bla bla").
I am looking for a tool which will do the job for me ;-)
I want it to replace automatically <brby <br/in my php page.
I want it to udpate the code. (actually TIDY do it It works even with
PHP page but with bugs!!)

I'm sure you understand that I need to do this step on the input (the
php page) instead of the output (or its work will be lost!!!!!).

And then you get a better understanding of the difference between
familly 1 and familly 2.

Obviously, if you want to validate the output, there is no difference
(who said it is what I want?). But if you need to validate the HTML
code from a php page, you will understand it will be easier to
validate HTML code if the php code is in the HTML (and not the
opposite, when HTML is in the php code).
And that's why it is always recommended to belong to the second
family ;-)

Rod
You've got it. It's called "Brain 1.0". And no program has replaced it
yet. That's what you get paid for.

--
==================
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
js*******@attglobal.net
==================
Apr 28 '07 #12
You want something to 'fix' the HTML code for you,

Yes, but only the HTML code that I have written in the php page.
It's easy enough to say, use the w3c validator and fix the HTML
yourself!
That's what I don't want to do ;-)
The tool you want would have to interpret PHP
Nooooooo (but I guess my english is too bad, so nobody understand me :
(
>and then 'validate' the *output* of your PHP script,
Nooooooo, I don't care about the output :(
and then somehow figure out where in the script
the
error came from... There are so many ways PHP can generate HTML,
No, no, definetely not, and PHP *will not generate HTML*.
>this would require a HUGE amount of intelligence. It would have to figure
out
how and where the HTML came from.
No, again. Actually, TIDY does it but with bugs

The number of ways PHP (or any program) can generate HTML (or anything
else) is infinite.
No, if you think in terms of XHTML validation. Definetely not.
No tool can be that smart.
Yes of course. TIDY team could fix their bugs or I could even do the
tool myself but I do not have time to spend with that, unfortunatelly.
I suppose it could be done if combined with some template based
programming
discipline, but it'd be easier to use the w3c validator to find the
errors, and your
knowledge of your script to figure out where that error came from.
Yes of course, but I am trying to figure how to avoid it.
If there is no solution, I will do it myself of course. I am just
looking for this tool, it could help now and in the future.

Now to explain why I am saying that php is not generating HTML, and
why I don't care about php code.
Here is an example of a code IN THE PHP page (this is not the output)

<?php for ($i=1;$i<=10;$i++) {?>
<img src="<?php echo $fileName[$i]?>" >
<a href="<?php echo $link[$i]?>" <?php echo $fileName[$i]?</a>
<br>
<?php } ?>

A clever tool could say: OK, I don't care about php code, even if PHP
is generating HTML, I don't care!!
I don't want to validate XHTML output!!!!! (I DO NOT CARE ABOUT THE
OUTPUT) . I just want to validate the XHTML in the PHP page.
SO it could translate this like that
//REMOVED PHP TAG
<img src="//REMOVED PHP TAG" >
<a href="//REMOVED PHP TAG"//REMOVED PHP TAG <br>
//REMOVED PHP TAG

then it could replace like that (by removing PHP code)
<img src="" >
<a href=""</a><br>

it could say now:
warning: alt is missing in the IMG tag
warning: IMG tas is not closed
warning: BR tag is not closed

Then it could update and provide:
<img src="" alt=""/>
<a href=""</a<br/>

Then It will put the code back:
//REMOVED PHP TAG
<img src="//REMOVED PHP TAG" alt="" />
<a href="//REMOVED PHP TAG"//REMOVED PHP TAG </a<br/>
//REMOVED PHP TAG

then:
<?php for ($i=1;$i<=10;$i++) {?>
<img src="<?php echo $fileName[$i]?>" alt="" />
<a href="<?php echo $link[$i]?>" <?php echo $fileName[$i]?</a>
<br/>
<?php } ?>

Do you see now what I mean? Tidy does this work, but unfortunatelly
with some bugs.
This is easy to do, just an algorithm. Everybody who writes a
compilator one day know how it is easy (grammar etc etc).

Of course, this is easy because your are inserting PHP code in HTML
tags, which is the best solution to do.
When you are developping, If you separate the layers you have 2 php
pages for each page:
page1=contains only php code (business layer)
page2 included at the end of page1 =contains ONLY HTML code with a
few php code ike "echo, if, while". The main rule is to put php within
HTML tags (like my example). The php code outside should never
generates HTML code. It should only be there to increment a loop or to
manage a loop.

Of course when I write this:
<?php for ($i=1;$i<=10;$i++) {?>
<img src="<?php echo $fileName[$i]?>" >
<?php } ?>

If you say that php is generating HTML code because it is repeating 10
times the <imgtag, then I understand why you don't understand what I
say!!
In this example I do not consider that PHP is really generating HTML
(it is repeating HTML code wich is *NOT* the same thing).
If you write this:
<?php echo"<img src="$fileName[$i]" >"
Then, php is genrating HTML code!! Everybody should avoid this, but
this is only my opinion.

The fact that PHP is repeating a line is not a problem with HTML
validation, because, if you are validating the HTML line (only 1),
then even if you duplicate this line ten times, the validation will
remain OK (maybe with some exceptions??).

That's why again I say it is easy. I really think you can validate
this:
<?php for ($i=1;$i<=10;$i++) {?>
<img src="<?php echo $fileName[$i]?>" >
<a href="<?php echo $link[$i]?>" <?php echo $fileName[$i]?</a>
<br>
<?php } ?>

without validating this:
<img src="file1" >
<a href="file1"file1</a<br>
<img src="file2" >
<a href="file2"file2</a<br>
<img src="file3" >
<a href="file3"file3</a<br>
<img src="file4" >
<a href="file4"file4</a<br>
.......... etc etc

Rod

Apr 29 '07 #13
On 28 avr, 03:13, Jerry Stuckle <jstuck...@attglobal.netwrote:
webrod wrote:
No, there is no difference. In either case you are using PHP to output
information to the page. Nothing more, nothing less. Zip. Nada.
This is because you are focusing on the outpout. As I said, YES the
output is EXACTLY the same, if you compare the generated HTML, I agree
this is the same.

Then who cares about how it's generated? I sure don't. You're fixating
on the details instead of the overall picture.
I don't care about the overall picture in this thread? (and who
cares?)
So what exactly do you want to validate? The only important things are
- the PHP code itself is valid (the interpreter will tell you if it's
not),
I don't care about the PHP code

Then don't worry about validating the source. Just use the HTML
validator to check the output.
And if I don't want?
You've got it. It's called "Brain 1.0". And no program has replaced it
yet. That's what you get paid for.
I'm not paid for that.I've spent a lot of years to develop php website
but now I'm .NET architect (so I'm not paid anymore to do php stuffs)
I do not have time to spend to manually update my 100 templates php
pages because this is to update a personal website.
So I'm not paid for, and even If I was, I'm not paid to lost my time.
I'm paid to do my job ASAP, I don't want to loose the money of my
company because YOU are against automation and tools ;-)

OK, so I guess you are paid to write php with Microsoft NOTEPAD
because:
- you don"t need a tool to validate in real time your php code (you
don't care because you have brain 1.0 so you never have errors in your
code)
- you don't need a tool to debug your code (you don't care because you
have brain 1.0 so you never have errors or bugs)
- you don't need a tool to provide auto-completion (you know all the
php functions, what they do and their parameters thanks to brain
1.0..)
- you don't need a tool to manage source code (CVS..) even when you
work in a team (you have a good communication in the team because you
have brain 1.0 , so who cares this tool??)
- actually you don't need a tool beacause your get paid for using your
brain and not tools(????)

Seriously, if you do not know the tool I am looking for, then don't
waste your time ;-)

Rod

--
==================
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
jstuck...@attglobal.net
==================- Masquer le texte des messages précédents -

- Afficher le texte des messages précédents -

Apr 29 '07 #14
Message-ID: <11*********************@u30g2000hsc.googlegroups. comfrom
webrod contained the following:
>The fact that PHP is repeating a line is not a problem with HTML
validation, because, if you are validating the HTML line (only 1),
then even if you duplicate this line ten times, the validation will
remain OK (maybe with some exceptions??).
Lots of exceptions

<?php if($something_is_true){ ?>
<div style='border:1px solid
red;padding:20px;margin:20px;text-align:center'>
<?php } ?>

<?php if($something_else_is_true){ ?>
<div style='border:1px solid
blue;padding:20px;margin:20px;text-align:center'>
some content
</div>
<?php } ?>

<?php if($something_is_true){ ?>
some more content
</div>
<?php } ?>

OK, you may /never/ code like this. But that's not the point. ASs far
as an automated tool is concerned that is perfectly valid code.

I can't see how you could possibly check the validity of the code
without parsing the php

--
Geoff Berrow (put thecat out to email)
It's only Usenet, no one dies.
My opinions, not the committee's, mine.
Simple RFDs http://www.ckdog.co.uk/rfdmaker/
Apr 29 '07 #15
webrod kirjoitti:
I do not have time to spend to manually update my 100 templates php
pages because this is to update a personal website.
If you would've mentioned this right from the beginnig, that your goal
is to fix a massive amount of pages, and we're not talking about fixing
a couple of <br>'s to <br /here and there, it would have given the
folks a lot better idea what you are actually trying to do. It's a whole
lotta easier to validate as you develop, and fix the errors right on the
spot. But in your case the damage is already done, and an automated
process is needed. I don't know if such a tool exists. You could
possibly write one. Something that takes a file and does some
preg_replaces and spits out a clean page. Altough it would take some
time which you don't have, so I guess it can't be helped but to keep on
looking for the tool and hope that someone out there has a similar
problem and a handy solution for it.
Seriously, if you do not know the tool I am looking for, then don't
waste your time ;-)
Seriously, if you dont explain all the details, and the purpouse the
tool is for, people are bound to waste their time. But as Louis
Armstrong sang, "We've got all the time in the world..." so we can waste
some time easily. I'm worried about you wasting your time since you
don't have any to waste.

--
Ra*********@gmail.com

"Wikipedia on vähän niinq internetin raamattu, kukaan ei pohjimmiltaan
usko siihen ja kukaan ei tiedä mikä pitää paikkansa." -- z00ze
Apr 29 '07 #16
webrod wrote:
On 28 avr, 03:13, Jerry Stuckle <jstuck...@attglobal.netwrote:
>webrod wrote:
>>>No, there is no difference. In either case you are using PHP to output
information to the page. Nothing more, nothing less. Zip. Nada.
This is because you are focusing on the outpout. As I said, YES the
output is EXACTLY the same, if you compare the generated HTML, I agree
this is the same.
Then who cares about how it's generated? I sure don't. You're fixating
on the details instead of the overall picture.

I don't care about the overall picture in this thread? (and who
cares?)
Who said anything about the overall picture in this thread? I'm talking
about your html.

PHP generates or controls the generation of html. That's what it does,
and if you want to validate your html you cannot ignore the php code.

>>>So what exactly do you want to validate? The only important things are
- the PHP code itself is valid (the interpreter will tell you if it's
not),
I don't care about the PHP code
Then don't worry about validating the source. Just use the HTML
validator to check the output.

And if I don't want?
Then don't come crying to us. You've been given a very valid solution
to your problem.
>You've got it. It's called "Brain 1.0". And no program has replaced it
yet. That's what you get paid for.

I'm not paid for that.I've spent a lot of years to develop php website
but now I'm .NET architect (so I'm not paid anymore to do php stuffs)
I do not have time to spend to manually update my 100 templates php
pages because this is to update a personal website.
So I'm not paid for, and even If I was, I'm not paid to lost my time.
I'm paid to do my job ASAP, I don't want to loose the money of my
company because YOU are against automation and tools ;-)
I don't care whether you're a .NET architect or a sewer cleaner. You're
being paid to do a job.

And if this is a personal website, you need to determine whether it's
worth your time to continue this website. It sounds like from your
arguments it isn't.
OK, so I guess you are paid to write php with Microsoft NOTEPAD
because:
- you don"t need a tool to validate in real time your php code (you
don't care because you have brain 1.0 so you never have errors in your
code)
- you don't need a tool to debug your code (you don't care because you
have brain 1.0 so you never have errors or bugs)
- you don't need a tool to provide auto-completion (you know all the
php functions, what they do and their parameters thanks to brain
1.0..)
- you don't need a tool to manage source code (CVS..) even when you
work in a team (you have a good communication in the team because you
have brain 1.0 , so who cares this tool??)
- actually you don't need a tool beacause your get paid for using your
brain and not tools(????)
I actually do use Notepad for some of my PHP code. Other times I use a
syntax-highlighting editor. But that's all.

Sure I have errors in my code. But I find them quickly. But I can
write and debug it faster than a lot of people can write with an IDE.
That's why I get paid well for what I do.

And no - I don't use autocompletion. I've tried it in the past - and
always turned it off. It gets in the way too much. I'm a touch typist
and seldom look at the screen.

Having a tool such as CVS has nothing to do with this conversation.

But no, I don't need all those "tools" you require.
Seriously, if you do not know the tool I am looking for, then don't
waste your time ;-)

Rod

I told you. Brain 1.0. But in your case it sounds like it's still in
alpha test.
>
>--
==================
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
jstuck...@attglobal.net
==================- Masquer le texte des messages précédents -

- Afficher le texte des messages précédents -


--
==================
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
js*******@attglobal.net
==================
Apr 29 '07 #17
On Apr 29, 4:39 am, Rami Elomaa <rami.elo...@gmail.comwrote:
webrod kirjoitti:
I do not have time to spend to manually update my 100 templates php
pages because this is to update a personal website.

If you would've mentioned this right from the beginnig, that your goal
is to fix a massive amount of pages, and we're not talking about fixing
a couple of <br>'s to <br /here and there, it would have given the
folks a lot better idea what you are actually trying to do.
What difference does it make? At what point, at what number of pages,
does such a tool become worthy of consideration? 5? 10? 100?

The logic of the problem is the same.

Apr 29 '07 #18
Don't know how to do such things with Unix, but on Windows
it's relatively easy to update alot of <brto <br />.

A proper editor can help you with much of the rest. SciTE is a
wonderful editor (http://scintilla.sourceforge.net/).

FrontPage is a great tool for doing "mass" updates to all files
within a website (for instance, changing all <brtags to <br />).

100 template pages, on the other hand can be edited by hand,
perhaps 10 to 20 per day? Regular Expression search and
replace works very well in such cases.

--
Jim Carlock
Apr 30 '07 #19
Geoff,

you say: " can't see how you could possibly check the validity of the
code
without parsing the php".
That's the point. You *do not need* to parse the php to validate the
XHTML if you code properly.

You're examples are very good.
Let's have a look:
<?php if($something_is_true){ ?>
<div style='border:1px solid
red;padding:20px;margin:20px;text-align:center'>
<?php } ?>
I you read my other messages, a tool like tidy could say: "I don't
care about php code, so I update the text like this":
//REMOVED PHP TAGS
<div style='border:1px solid
red;padding:20px;margin:20px;text-align:center'>
//removed PHP TAGS

so I parse only:
<div style='border:1px solid
red;padding:20px;margin:20px;text-align:center'>

So where is the need to validate PHP code??
Anyway PHP code validation is done by a real development tool in the
very first step (like ZEND).

Again here:
<?php if($something_else_is_true){ ?>
<div style='border:1px solid
blue;padding:20px;margin:20px;text-align:center'>
some content
</div>
<?php } ?>

It could be updated like this by a tool like TIDY:
//REMOVED PHP TAGS
<div style='border:1px solid
blue;padding:20px;margin:20px;text-align:center'>
some content
</div>
//REMOVED PHP TAGS

so:
<div style='border:1px solid
blue;padding:20px;margin:20px;text-align:center'>
some content
</div>

etc etc
OK, you may /never/ code like this. But that's not the point.
yes, you're right, this is out of scope, My apologies.
Rod

Apr 30 '07 #20
If you would've mentioned this right from the beginnig, that your goal
is to fix a massive amount of pages, and we're not talking about fixing
a couple of <br>'s to <br /here and there, it would have given the
folks a lot better idea what you are actually trying to do.
Actually, my first sentence in my first message was:
"I have some php pages with a lot of HTML code."
Maybe I should add "already" to say:
"I already have some php pages with a lot of HTML code."
Don't know as I'm not very good in english.
On the other hand, I have never said that I only wanted to update <br>
to <br/>.
I said somewhere in my messages "for example: <brto <br/>"
I apologies if it was not clear enough.

To explain you what I am doing that, I heard that you can improve you
page rank (from google) If you are XHTML compliant. I realized that I
did a lot of mistake. For example I used <brinstead of <br>, or
sometimes even <BR(it should not be upper case) etc etc.(a lot of
other problems).
That's why I would like to update my 100 templates.

Anyway, thanks for your clear answer (you explained my problem better
than me!!)

Rod

Apr 30 '07 #21
PHP generates or controls the generation of html. That's what it does,
and if you want to validate your html you cannot ignore the php code.
You really misunderstand everything :(
But anyway, think what you want to think. I even guess you are not
alone.

And if I don't want?

Then don't come crying to us.
Who is crying?
You've been given a very valid solution
to your problem.
really? I'm not looking for a solution but for a tool. Did I give the
name of a tool???

I don't care whether you're a .NET architect or a sewer cleaner. You're
being paid to do a job.
Again, why are you wasting you're time to say stupid things??
Do you read what you write??
ok, and If I say that I am a florist? Are you still saying " you're
being paid to do a job." ??
I think you like to say "general thinks" like:
- you're being paid to do a job.
- sky is blue
- php is generating HTML

WHat you don't see in what you say is that:
- you're being paid to do a job.=yes of course, as everybody in the
world who has a job, but, hey I'm a florist!! So what is the relation
between the fact that I am paid to sell flowers and the fact that I am
looking for a tool to validate XHTML?? Actually in reality: "So what
is the relation between the fact that I am paid to develop .NET
solutions and the fact that I am looking for a tool to validate XHTML
for my personal website?? If you don't understand the difference
then......
- sky is blue =not always, sometimes it is not. But yes, you're
right, we can say that the sky is blue
- php is generating HTML =not always, it depends how you develop and
what you mean by "generating"
I actually do use Notepad for some of my PHP code. Other times I use a
syntax-highlighting editor. But that's all.
Yes, I knew ;-) It was sure!!
Sure I have errors in my code. But I find them quickly. But I can
write and debug it faster than a lot of people can write with an IDE.
Yes, because YOU are the best! Congratulations!
That's why I get paid well for what I do.
I don't think you are paid to develop any kind of applications!! This
is again sure!
And no - I don't use autocompletion. I've tried it in the past - and
always turned it off. It gets in the way too much. I'm a touch typist
and seldom look at the screen.
Of course.... Congratulations ;-)
Having a tool such as CVS has nothing to do with this conversation.
Yes, it is, but I understand that you do not understand
But no, I don't need all those "tools" you require.
Of course not, you are the best. And I agree that you do need any
tools in a team of 5 people with:
- you
- you
- you
- you
- and... you
I told you. Brain 1.0. But in your case it sounds like it's still in
alpha test.
Yes, I'm trying to get the beta one ;-)
I know that you have Brain 12.9 and to tell you the true, I am really
impressed.

Great threads ;-)
Rod

Apr 30 '07 #22
Message-ID: <11*********************@c35g2000hsg.googlegroups. comfrom
webrod contained the following:
>
you say: " can't see how you could possibly check the validity of the
code
without parsing the php".
That's the point. You *do not need* to parse the php to validate the
XHTML if you code properly.
Unfortunately an automated tool has to work in all situations.
--
Geoff Berrow (put thecat out to email)
It's only Usenet, no one dies.
My opinions, not the committee's, mine.
Simple RFDs http://www.ckdog.co.uk/rfdmaker/
Apr 30 '07 #23
Unfortunately an automated tool has to work in all situations.

OK, so do you see other situations which could be a problem?
Give examples.

Rod

Apr 30 '07 #24
Message-ID: <11**********************@n76g2000hsh.googlegroups .comfrom
webrod contained the following:
>Unfortunately an automated tool has to work in all situations.

OK, so do you see other situations which could be a problem?
Give examples.
<?php if($something_is_true){ ?>
<span style='border:1px solid
red;padding:20px;margin:20px;text-align:center'>
<?php } ?>

<?php if(!$something_is_true){ ?>
<div style='border:1px solid
blue;padding:20px;margin:20px;text-align:center'>
some content
</div>
<?php } ?>

<?php if(!$something_is_true){ ?>
some more content
</div>
<?php } ?>
<?php if($something_is_true){ ?>
</span>
<?php } ?>

Removing all the PHP you have a div inside a span though that could
never happen.

--
Geoff Berrow (put thecat out to email)
It's only Usenet, no one dies.
My opinions, not the committee's, mine.
Simple RFDs http://www.ckdog.co.uk/rfdmaker/
Apr 30 '07 #25
webrod wrote:
>PHP generates or controls the generation of html. That's what it does,
and if you want to validate your html you cannot ignore the php code.

You really misunderstand everything :(
But anyway, think what you want to think. I even guess you are not
alone.

>>And if I don't want?
Then don't come crying to us.

Who is crying?
> You've been given a very valid solution
to your problem.

really? I'm not looking for a solution but for a tool. Did I give the
name of a tool???

>I don't care whether you're a .NET architect or a sewer cleaner. You're
being paid to do a job.

Again, why are you wasting you're time to say stupid things??
Do you read what you write??
ok, and If I say that I am a florist? Are you still saying " you're
being paid to do a job." ??
I think you like to say "general thinks" like:
- you're being paid to do a job.
- sky is blue
- php is generating HTML

WHat you don't see in what you say is that:
- you're being paid to do a job.=yes of course, as everybody in the
world who has a job, but, hey I'm a florist!! So what is the relation
between the fact that I am paid to sell flowers and the fact that I am
looking for a tool to validate XHTML?? Actually in reality: "So what
is the relation between the fact that I am paid to develop .NET
solutions and the fact that I am looking for a tool to validate XHTML
for my personal website?? If you don't understand the difference
then......
- sky is blue =not always, sometimes it is not. But yes, you're
right, we can say that the sky is blue
- php is generating HTML =not always, it depends how you develop and
what you mean by "generating"
>I actually do use Notepad for some of my PHP code. Other times I use a
syntax-highlighting editor. But that's all.

Yes, I knew ;-) It was sure!!
>Sure I have errors in my code. But I find them quickly. But I can
write and debug it faster than a lot of people can write with an IDE.

Yes, because YOU are the best! Congratulations!
>That's why I get paid well for what I do.

I don't think you are paid to develop any kind of applications!! This
is again sure!
In your dreams. For your information, I've been programming for almost
40 years - and been an independent computer consultant for 17 years. I
get paid well for what I do - which includes developing applications as
well as web pages.
>And no - I don't use autocompletion. I've tried it in the past - and
always turned it off. It gets in the way too much. I'm a touch typist
and seldom look at the screen.

Of course.... Congratulations ;-)
>Having a tool such as CVS has nothing to do with this conversation.

Yes, it is, but I understand that you do not understand
No, I understand completely. You just don't understand how the real
world works.
>But no, I don't need all those "tools" you require.

Of course not, you are the best. And I agree that you do need any
tools in a team of 5 people with:
- you
- you
- you
- you
- and... you
>I told you. Brain 1.0. But in your case it sounds like it's still in
alpha test.

Yes, I'm trying to get the beta one ;-)
I know that you have Brain 12.9 and to tell you the true, I am really
impressed.

Great threads ;-)
Rod

--
==================
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
js*******@attglobal.net
==================
Apr 30 '07 #26
To answer the original question, webrod, you can try enabling output
buffering, and then running Tidy on the contents of that. It's as
simple as adding this to the top of your PHP scripts:

<?php
ob_start('ob_tidyhandler');
?>

Although your mileage may vary depending on the version of Tidy and
PHP on your server. For more information, consult the manual:

http://php.net/manual/en/ref.outcontrol.php - Output Buffering
http://php.net/manual/en/ref.tidy.php

May 19 '07 #27

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

Similar topics

2
by: deko | last post by:
I use variables in some links on my page. I need to send these variables so I can change the color of the links in the navbar when the user is on that page. If you click around on the site you...
33
by: LRW | last post by:
http://gto.ie-studios.net/index.php When you view the above site in IE, if the 1st of the three product images is tall enough to push the cell down a couple of pixels, IE somehow doesn't show...
16
by: graham.reeds | last post by:
I am updating a website that uses a countdown script embedded on the page. When the page is served the var's are set to how long the countdown has left in minutes and seconds, but the rest of the...
4
by: Ganesh Muthuvelu | last post by:
Hello, I was wondering if there is a way to store all the HTML element information in a database and then dynamically generate the HTML code for a page?.. Basically, I do not want to design every...
19
by: thisis | last post by:
Hi All, i have this.asp page: <script type="text/vbscript"> Function myFunc(val1ok, val2ok) ' do something ok myFunc = " return something ok" End Function </script>
3
by: dmans | last post by:
Does anyone have an idea how to validate HTML in a given post. It doesn't have to be perfect XHTML standard, just something to catch html tags that are not closed so that it doesn't mess up the site....
2
by: hellohi | last post by:
i want to validate the HTML code \\ is it possible. if yes , give the code
1
by: Andy Dingley | last post by:
On 31 Jul 2008 16:22:51 GMT, "mark4asp" <mark4asp@gmail.comwrote: It's hard to programatically validate HTML. You need to use Jade, because Mere Mortals don't get to go near the code that does...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
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...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
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...

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.