PHP in HTML

JavaScript and client side scripting.

Moderator: General Moderators

Post Reply
marvinz
Forum Newbie
Posts: 1
Joined: Fri Jul 11, 2003 2:33 am

PHP in HTML

Post by marvinz »

Hi,

I'm a newbie to PHP and from what I saw it seems impossible to use PHP code in a .html file unless you configure the server to parse html files as php.

However, if there is a function in a php file, let's call it function.php, and I want to acces it from, say, example.html, is it possible to include in the latter <script language="php" src="function.php></script> at the point where I want to implement it?

Why wouldn't that work?

Thanks.
User avatar
redhair
Forum Contributor
Posts: 300
Joined: Fri May 30, 2003 4:36 pm
Location: 53.23N-6.57E
Contact:

Re: PHP in HTML

Post by redhair »

marvinz wrote:Why wouldn't that work?
<script language="php" src="function.php></script> would suggest that php is a client side scripting languige..however..it is server sided.
Browsers dont have php plugins ;-)
User avatar
igoy
Forum Contributor
Posts: 203
Joined: Fri May 02, 2003 11:57 pm
Location: India
Contact:

Post by igoy »

True .. . Browser reads that kind of stuff on Client System. . while PHP runs on Server Side and outputs HTML which is shown in browser...

Please try to understand process flow, and you will get answer for your question.

in case of HTML, javascript :

Code: Select all

client request -> server -> HTML page -> browser -> render HTML / javascript & show

in case of PHP :

Code: Select all

client request -> server -> PHP script -> output -> browser -> render HTML & show
if you see what happenes here, you will come to know
" Why wouldn't that work? "
Post Reply