Call a PHP file from HTML

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
loxley
Forum Newbie
Posts: 2
Joined: Fri Aug 25, 2006 6:39 am

Call a PHP file from HTML

Post by loxley »

Hi folks, sorry about this but I have a real irritation with this little issue.

I have a php file that when exectued returns a random text quote (straight foward).

I have a html file in the same folder that I want to return the random quote into.

Can anyone tell me a way that I can call the php file from within my HTML file to
simply return the PHP file result??

I'm loosing my marbles over this and have tried just about everything I can :(

Sorry for bieng a dork, but if ya don't know ya don't know I guess :oops:

Many thanks
richo
Forum Commoner
Posts: 58
Joined: Sun Aug 06, 2006 11:56 am

Post by richo »

could you not make the HTML file a PHP file and do a

Code: Select all

require
?
User avatar
JayBird
Admin
Posts: 4524
Joined: Wed Aug 13, 2003 7:02 am
Location: York, UK
Contact:

Post by JayBird »

You cant unless you tell your server to parse HTML files as PHP.

Or you could just rename your HTML file to fileName.php
User avatar
Jenk
DevNet Master
Posts: 3587
Joined: Mon Sep 19, 2005 6:24 am
Location: London

Post by Jenk »

You can't :)

PHP is executed server side, HTML is client side :)

Amend the PHP file to output the required HTML :)
loxley
Forum Newbie
Posts: 2
Joined: Fri Aug 25, 2006 6:39 am

Post by loxley »

Thanks for the feedback, renamed file, used require and . . .

yet again my neck has been saved!

Thanks all, I'll get than hang of this PHP sooner or later?

Have a good weekend all
Post Reply