Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How to call php file in XHTML? 1

Status
Not open for further replies.

MasumX

Programmer
Feb 19, 2005
26
0
0
US
Hi, how do i include a .php extention file in "XHTML"? when i used the php syntax it gave me a error saying

Line 161, column 34: processing instruction does not start with name

<? include("random.php") ?>


so can anyone help? how i can include the file by calling the php file :)? thanks!
 
Ermmmm ... I was under the impression that PHP should only run server-side - to then generate HTML/CSS/JavaScript dynamically (which is what any *validator* should see) - so I'm not following the point of posting a link to an HTML file that happens to have some PHP in it ?!

--------------------------------------------------
Free Database Connection Pooling Software
 
The link to was to prove that you can view a file that does not have a PHP extension.

Holy Cow! And this whole time I thought PHP was the only doc type that was visible!

As Sheco said, you can stick PHP, Assembly, Cobol, Fortran, or baby talk into an HTML page. Doesn't mean it will freaking work. But it'll be there. Seeing as how it doesn't work though, it makes the whole thing rather pointless.

-Rick

----------------------
[banghead]If you're about to post an ASP.Net question,
please don't do it in the VB.Net forum[banghead]

[monkey] I believe in killer coding ninja monkeys.[monkey]
 
Well of course you can view a file without a PHP extension - check out my site - its mainly JSP (and certainly not XHTML, I haven't got time for that ****) - and you can also view the files too :)


--------------------------------------------------
Free Database Connection Pooling Software
 
Clive.

<?php ?>, <? ?> and <script language="php"></script> will all function in the same fashion PROVIDED THE PAGE IS BEING PROCCESSED AS PHP and therefore they do not need to validate at all as they will NEVER appear in the client side source.
Your discussion on the merits of one validating is simply not of any consequence as it should never happen when used correctly.


Chris.

Indifference will be the downfall of mankind, but who cares?
Woo Hoo! the cobblers kids get new shoes.
People Counting Systems

So long, and thanks for all the fish.
 
1. To get the error the originator must have been validating locally.

2. <script language="php"> is the same as <? or <?php

3. The reason I showed test.htm was because someone had suggested that you could call a PHP file by any extension as long as you configured the PHP processor.

Have a nice day!

Clive
 
If your server side code is showing up in your browser then something is wrong... it isn't being processed by the server.

Don't worry about it not validating until you fix this underlying problem!

Unless, of course, you are making a web page about how to write server-side code and the "code" in that case is just the text of your examples.

But if that is what you are doing there is no need for the <script> tags because the code is just text anyhow.
 
What was actual problem?

a) XHTML file won't validate
b) output generated by random.php won't include
c) both

-------------
wow, alot of replies cool :p umm im using XHTML so i tried to "Include" a .php extension file to call a random.php and that error showed up when i tried to validate it from validator.w3.org and maybe i can use the method CliveC used..with Javascript to call the php file!! eh? oh btw loving this forum :D
 
I hope this works out like the validating of dates using regular expressions.


Keith


The most likely way for the world to be destroyed, most experts agree, is by accident. That's where we come in; we're computer professionals. We cause accidents.
 
CliveC, Thanks..and it worked :D and No error when i validated :)cooL!
 
Maybe I'm missing something here. Why would you validate a page before it is processed by PHP? If the PHP generates output, that output would never get validated, right?

Oh, and..
CliveC said:
klaforc, When I was wrong I admitted it. See the difference here?
Actually, you admitted it long long after you were wrong. It was like pulling teeth!

Adam

There are only 10 types of people in the world: Those who understand binary, and those who don't
 
Mr Vibrating: I told you I'm not allowed to argue unless you've paid.
Man: I've just paid.
Mr Vibrating: No you didn't.
Man: I did! I did! I did!
Mr Vibrating: No you didn't.
Man: Look I don't want to argue about that.
(Couldn't help myself.) [smile]
 
damn...the things already works? and what's the arguement is about lost since i waznt paying attention to everything..unless it was to help me that is :D
 
ok sorry but i just realized it dnt work like this..

<script language="php" type="text/php">
include('random.php')
</script>

it work as <script language="php">
include('random.php')
</script>

but doesn't validate without "type" attribute
 
but this seems to work and validate without error

<?php include("random.php"); ?>
 
The whole point of the matter is that anything that is between server-side script delimiters <? ?> or <?php ?> for PHP or <% %> for ASP does not need to validate. It should not be even parsed by the validator. ALL validators should treat server side delimiters in the same way they should treat client side <script></script> delimiters and ignore anything inbetween IF you are validating a file rather than the SERVED document. This is for the very basic reason that they should never appear in the served document, the output from the script or the contents of the included file will do but not the delimiters.

However in reality you should not validate any documents that are using SSI or scripted includes without them being served up. This is simply because you are not validating the entire document as delivered to the user agent, only part of it.


Chris.

Indifference will be the downfall of mankind, but who cares?
Woo Hoo! the cobblers kids get new shoes.
People Counting Systems

So long, and thanks for all the fish.
 
Ah Chris, but this question is only for people who write PHP stuff to go on servers that can't process PHP. [lol]

________________________________________________________________
If you want to get the best response to a question, please check out FAQ222-2244 first
'If we're supposed to work in Hex, why have we only got A fingers?'
Essex Steam UK for steam enthusiasts
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top