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!
 
What MasumX is doing is putting a PHP server side scripting function call on an XHTML page. All PHP has to be processed on the server, so you'd have to set up your server to run whatever extension you have on this page (.html, .htm, .xml, etc) through the PHP processor first.

Lee
 
Yes, that is syntactically correct but for this problem difference between <?, <? php and <script language="php"> is irrelevant.

"processing instruction does not start with name" error is W3C/X(HT)ML validator thing. MasumX probably attempted to includes PHP island within .XHTML file. Because server is configured to pass-thru .XHTML files, this won't work. Two ways to solve this:

a) configure server to preprocess .XHTML files with PHP
b) use vanilla .PHP URL that generates XHTML and eventually sets HTTP Content-type

------
heisenbug: A bug that disappears or alters its behavior when one attempts to probe or isolate it
schroedinbug: A bug that doesn't appear until someone reads source code and realizes it never should have worked, at which point the program promptly stops working for everybody until fixed.

[ba
 
Does anyone have any good links that explain how to use PHP to write realtime drivers for embedded devices? Specifically I would like to use PHP to for motor control on a linear actuator. Thsnks!!1one!1
 
With or without transdimensional frobnicator? Ya know, this makes a biiig difference.

(j/k)

------
heisenbug: A bug that disappears or alters its behavior when one attempts to probe or isolate it
schroedinbug: A bug that doesn't appear until someone reads source code and realizes it never should have worked, at which point the program promptly stops working for everybody until fixed.

[ba
 
No, you can set the PHP processor to handle other extensions without a problem, and process the script in them before sending the final result to the client.

Lee
 
Code:
The Web Design Group
HTML Validation Results
Document Checked

    * Character encoding: UTF-8
    * Level of HTML: XHTML 1.0 Transitional

Congratulations, no errors!
Input

 1   <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
 2   "[URL unfurl="true"]http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">[/URL]
 3   <html xmlns="[URL unfurl="true"]http://www.w3.org/1999/xhtml"[/URL] xml:lang="en" lang="en">
 4   <head><title>PHP includes</title>
 5   <meta http-equiv="Content-Type" content="text/html;charset=utf-8" />
 6   </head><body>
 7   <script language="php" type="text/php">
 8   include('fsethgen.php');
 9   </script>
10   </body></html>

Clive
 
Urgh... I suggest we stop chasing our tails until original poster answers on following question:

What was actual problem?

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

------
heisenbug: A bug that disappears or alters its behavior when one attempts to probe or isolate it
schroedinbug: A bug that doesn't appear until someone reads source code and realizes it never should have worked, at which point the program promptly stops working for everybody until fixed.

[ba
 
Caring for Your Cat: The Top Ten Essentials

1. Outfit your cat with a collar and ID tag that includes your name, address, and telephone number.
2. Follow local cat registration laws.
3. Keep your cat indoors.
4. Take your cat to the veterinarian for regular check-ups.
5. Spay or neuter your pet.
6. Give your cat a nutritionally balanced diet, including constant access to fresh water.
7. Train your cat to refrain from undesirable behaviors such as scratching furniture and jumping on countertops.
8. Groom your cat often to keep her coat healthy, soft, and shiny.
9. Set aside time to play with your cat.
10. Be loyal to and patient with your cat.

----------------------
[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]
 
It doesn't matter if you surround it with script tags and it validates or not. The simple fact is it SHOULDN'T[/b} be in the page source. It is only there because the server is NOT sending the page through the PHP processor.

Simple!!!!!

stop confusing the issue with irrelevancies. The PHP code and tags shouldn't be there FULL STOP



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.
 
It doesn't matter if you surround it with script tags and it validates or not. The simple fact is it SHOULDN'T be in the page source. It is only there because the server is NOT sending the page through the PHP processor.

<?, <?php and <script language="php"> all do the same thing. Some validate some do not.

Clive
 
I like to write raw x86 assembly in my pages.

It isn't hard to get them to validate ...
Code:
<!--
        pushl %ebp
        movl %esp,%ebp
        subl $8,%esp
        movl $10,-4(%ebp)  
        movl -4(%ebp),%edx 
-->

See, the secret is to use a magical character sequence! All of your assembly must begin with <!-- and end with --> only then will it validate!

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top