Forum Moderators: coopster

Message Too Old, No Replies

<script> tag for php file

<script> tag for php file

         

ravianz

5:01 am on Oct 31, 2005 (gmt 0)

10+ Year Member



Hi!
as we can use a javascript using
<script src="xyz.js"></script> tag in .htm file.
can we use such a script for a php file?
infect i want to use a php counter on htm page but want to avoid <iframe> tag?
in the php file after some commands one variable is displayed like
echo $count;
i've tried using
<script src="http://domin.ext/counter.php"></script>
but its not showing the variable value though counter works in this way i.e. counter is incremented but not displayed on .htm page;
I have also the tried script tag for a php file having a single echo statement for variable as well for string; also i have tried image on php file bt no display;
please help me out if it is possible to display php file in this way...

jatar_k

4:00 pm on Oct 31, 2005 (gmt 0)

WebmasterWorld Administrator 10+ Year Member



I would guess that your .htm files aren't being parsed for php

if you have the ability to use an .htaccess file you could add this functionality to .htm files.

mike73

9:00 pm on Nov 1, 2005 (gmt 0)

10+ Year Member



change your HTML files to PHP and use PHP's include function instead.

chrisjoha

7:38 am on Nov 2, 2005 (gmt 0)

10+ Year Member



The <script> tag is for including client side scripts. PHP is a server side script and can not be included like this. If you want to include the script on your page you can do one of the suggestions posted here.

Either make a .htaccess file (if you have that option) that holds this line:

AddType application/x-httpd-php .html .php

This will make sure html-files are parsed as php. OR you could rename the file to php.

Either way you can now write php code inside <?php?>
You can then include the script with <?php require_once('script.php');?>