Welcome to WebmasterWorld Guest from 184.108.40.206
I usually don't give two squirts about validating my HTML, but I am building a site from scratch and have worked for hours tonight on getting it to validate as 4.01 Trans. Guess what? I did it!
I am also testing in Mozilla, Opera, NS4 and IE to ensure that the site works.
Everything looks good and W3C validator nails me on the TYPE statement in my calls to the scripts I use. No problem. I put in the text/cgi and that clears. I put in TYPE=PHP and I am validated.
I go back to testing with the browser, but now Mozilla doesn't display the PHP script output. IE, Opera work fine. NS4 just dies when it hits that part.
I have tried:
TYPE = "PHP"
TYPE = "php"
TYPE = "text/php"
No dice. I have scoured the internet looking for an example, but cannot find one.
Can someone shoot a non-HTML expert a lifeline? I checked the W3C site, but couldn't find specific info on it.
Can you post the offending statement?
PHP is all server processed. None of it(unless something goes wrong) is output back to the browser, so you shouldn't be trying to validate it. You should be running the page, getting the result, and validating that.
Here is the simple statement:
The validator says I need a TYPE = statement in there. For the SSI CGI scripts I run I added TYPE=text/CGI and it worked.
From the snippets I found on the net TYPE = PHP should work, but doesn't in Mozilla or NS4.
Have you tried replacing '<script language="php">...</script>' with '<?php php code goes here?>'? Either way, no browser or validator should ever see the PHP script code at all. It's server-side scripting, not client-side.
I've never once used <script> tags for my PHP, and I *always* validate my code. It works fine, because what needs to validate isn't whatever.php, it's the output from whatever.php that gets sent to the browser when someone requents whatever.php.
<added> maybe you want <?php include("idya/ad.php");?> </added>
I can understand that. I guess what I am asking is when you call a PHP script from an HTML page which TYPE = do you specify?
A simplyfied step-by-step guide of a request to a PHP script:
<body><p>Aaron <?php echo "rocks!"?></p></body>
<html>to the web server.
Hope this helps.
I think pgrote may have been lead astray by the fact that '<script language="php"> php code here </script>' is valid PHP syntax, as an alternative to '<?php php code here?>'. I don't know why anyone would choose to use that syntax, but it's listed as an option in the laguage reference portion of the manual.
Notwithstanding the fact that it's allowed, I think it's a bad idea. Using a <script> tag would make me expect the contents to be processed by the browser, not the server. In the case of PHP, that's wrong.
As Andreas said, you can't call a PHP file from an HTML file, because the server will skip the step of parsing and executing the PHP, so it never interprets your 'call', and the browser can't.
I didn´t know that <script type="php"></script> was a valid way of escaping PHP from HTML. Thanks for enlightening us.
I don't know why anyone would choose to use that syntax
I was wondering that too after I read your post. php.net has an answer [php.net] for that as well:
echo ("some editors (like FrontPage) don't
like processing instructions");
Those script tags look exactly like the HTML ones, but they are not, since they are striped off by the PHP engine. Under normal circumstances no UA will ever see them.