Page 1 of 1

PHP in HTML

Posted: Fri Jul 11, 2003 2:33 am
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.

Re: PHP in HTML

Posted: Fri Jul 11, 2003 3:56 am
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 ;-)

Posted: Fri Jul 11, 2003 11:14 am
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? "