PHWinfo banniere

Titres
PORTAIL ANNUAIRE ARTICLES COMPARATEUR HÉBERGEURS DEVIS FORUMS RÉDUCTEUR D'URL
Précédent   PHWinfo > Forums Hébergement > Forum Serveur - Sécurité et techniques > alt.apache.configuration > embed PHP in HTML file
S'inscrire FAQ Membres Recherche Messages du jour Marquer les forums comme lus
alt.apache.configuration Apache web server configuration issues.

embed PHP in HTML file

Réponse
 
LinkBack Outils de la discussion
Vieux 11/02/2008, 17h17   #1
Paul Pedersen
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut embed PHP in HTML file

I have the following HTML file:

(test.html)

<HTML>

This is in the HTML section.

<?php
$v1 = "<BR>And this is ";
$v2 = "in the PHP section.";
echo $v1 . $v2;
?>

</HTML>


When I access that file with my local copy of Apache 2.2.8, I get this:

This is in the HTML section.
And this is in the PHP section.


But when I load test.html from my shared web hosting account running Apache
1.3.3, I get this:

This is in the HTML section. And this is "; $v2 = "in the PHP section.";
echo $v1 .$v2; ?>


My local server does what I expect, but the shared host server just passes
on (some of) the php code. If I change the name of the file from test.html
to test.php, it works.


Why does an html extension work on my local server but not on the remote
one? Is it because of the older version of Apache? Or is there a setting
that must be changed?






  Réponse avec citation
Vieux 11/02/2008, 17h34   #2
Lars
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: embed PHP in HTML file

Hi

Does you shared Apache server load the right PHP in the httpd.conf file?
Doesn't seam that way.

As a suggestion I would recoment you to split the document int one PHP and
one HTML file.


file phpfile.php
<?php

$v1 = "<BR>And this is ";
$v2 = "in the PHP section.";

// Note that I changed to printf in steat of echo
printf("%s %s\n", $v1 . $v2 );

?>


htm file
<HTML>

This is in the HTML section.

<?php
#nclude "phpfile.php"
?>





Lars


"Paul Pedersen" <nospam@no.spam> skrev i meddelandet
news:we-dndIWpLOnHi3anZ2dnUVZ_jednZ2d@comcast.com...
>I have the following HTML file:
>
> (test.html)
>
> <HTML>
>
> This is in the HTML section.
>
> <?php
> $v1 = "<BR>And this is ";
> $v2 = "in the PHP section.";
> echo $v1 . $v2;
> ?>
>
> </HTML>
>
>
> When I access that file with my local copy of Apache 2.2.8, I get this:
>
> This is in the HTML section.
> And this is in the PHP section.
>
>
> But when I load test.html from my shared web hosting account running
> Apache 1.3.3, I get this:
>
> This is in the HTML section. And this is "; $v2 = "in the PHP section.";
> echo $v1 .$v2; ?>
>
>
> My local server does what I expect, but the shared host server just passes
> on (some of) the php code. If I change the name of the file from test.html
> to test.php, it works.
>
>
> Why does an html extension work on my local server but not on the remote
> one? Is it because of the older version of Apache? Or is there a setting
> that must be changed?
>
>
>
>
>
>



  Réponse avec citation
Vieux 11/02/2008, 18h14   #3
Paul Pedersen
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: embed PHP in HTML file

Thank you for your response.

No, that does not work. (I had to tweak your example a little.)

The same thing happens - it works fine on my local 2.2.8 Apache, but the
remote 1.3.3 Apache simply returns the <?php ... ?> section literally:

<HTML>

This is in the HTML section.

<?php
include("phpfile.php");
?>

</HTML>


"Lars" <jon.doe@xxxxxxxxxxxxxxxxxx.xxx> wrote in message
news:xG%rj.3749$R_4.2531@newsb.telia.net...
> Hi
>
> Does you shared Apache server load the right PHP in the httpd.conf file?
> Doesn't seam that way.
>
> As a suggestion I would recoment you to split the document int one PHP and
> one HTML file.
>
>
> file phpfile.php
> <?php
>
> $v1 = "<BR>And this is ";
> $v2 = "in the PHP section.";
>
> // Note that I changed to printf in steat of echo
> printf("%s %s\n", $v1 . $v2 );
>
> ?>
>
>
> htm file
> <HTML>
>
> This is in the HTML section.
>
> <?php
> #nclude "phpfile.php"
> ?>
>
>
>
>
>
> Lars
>
>
> "Paul Pedersen" <nospam@no.spam> skrev i meddelandet
> news:we-dndIWpLOnHi3anZ2dnUVZ_jednZ2d@comcast.com...
>>I have the following HTML file:
>>
>> (test.html)
>>
>> <HTML>
>>
>> This is in the HTML section.
>>
>> <?php
>> $v1 = "<BR>And this is ";
>> $v2 = "in the PHP section.";
>> echo $v1 . $v2;
>> ?>
>>
>> </HTML>
>>
>>
>> When I access that file with my local copy of Apache 2.2.8, I get this:
>>
>> This is in the HTML section.
>> And this is in the PHP section.
>>
>>
>> But when I load test.html from my shared web hosting account running
>> Apache 1.3.3, I get this:
>>
>> This is in the HTML section. And this is "; $v2 = "in the PHP section.";
>> echo $v1 .$v2; ?>
>>
>>
>> My local server does what I expect, but the shared host server just
>> passes on (some of) the php code. If I change the name of the file from
>> test.html to test.php, it works.
>>
>>
>> Why does an html extension work on my local server but not on the remote
>> one? Is it because of the older version of Apache? Or is there a setting
>> that must be changed?
>>
>>
>>
>>
>>
>>

>
>



  Réponse avec citation
Vieux 11/02/2008, 22h32   #4
Lars
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: embed PHP in HTML file


"Paul Pedersen" <nospam@no.spam> skrev i meddelandet
news:gbudndc9QfYLDS3anZ2dnUVZ_o6knZ2d@comcast.com. ..
> Thank you for your response.
>
> No, that does not work. (I had to tweak your example a little.)
>
> The same thing happens - it works fine on my local 2.2.8 Apache, but the
> remote 1.3.3 Apache simply returns the <?php ... ?> section literally:


Does Apache 1.3.3 support inline PHP scripting in HTML files.

Try moving the script to another file and see what happens.

Or try this

Write a file that exactly as this. Save it as phpinfo.php then upload the
file and access it. You get lots of information about you server this way.

<?php
phpinfo();
?>

Outputs a large amount of information about the current state of PHP. This
includes information about PHP compilation options and extensions, the PHP
version, server information and environment (if compiled as a module), the
PHP environment, OS version information, paths, master and local values of
configuration options, HTTP headers, and the PHP License.

Lars

>
> <HTML>
>
> This is in the HTML section.
>
> <?php
> include("phpfile.php");
> ?>
>
> </HTML>
>
>
> "Lars" <jon.doe@xxxxxxxxxxxxxxxxxx.xxx> wrote in message
> news:xG%rj.3749$R_4.2531@newsb.telia.net...
>> Hi
>>
>> Does you shared Apache server load the right PHP in the httpd.conf file?
>> Doesn't seam that way.
>>
>> As a suggestion I would recoment you to split the document int one PHP
>> and one HTML file.
>>
>>
>> file phpfile.php
>> <?php
>>
>> $v1 = "<BR>And this is ";
>> $v2 = "in the PHP section.";
>>
>> // Note that I changed to printf in steat of echo
>> printf("%s %s\n", $v1 . $v2 );
>>
>> ?>
>>
>>
>> htm file
>> <HTML>
>>
>> This is in the HTML section.
>>
>> <?php
>> #nclude "phpfile.php"
>> ?>
>>
>>
>>
>>
>>
>> Lars
>>
>>
>> "Paul Pedersen" <nospam@no.spam> skrev i meddelandet
>> news:we-dndIWpLOnHi3anZ2dnUVZ_jednZ2d@comcast.com...
>>>I have the following HTML file:
>>>
>>> (test.html)
>>>
>>> <HTML>
>>>
>>> This is in the HTML section.
>>>
>>> <?php
>>> $v1 = "<BR>And this is ";
>>> $v2 = "in the PHP section.";
>>> echo $v1 . $v2;
>>> ?>
>>>
>>> </HTML>
>>>
>>>
>>> When I access that file with my local copy of Apache 2.2.8, I get this:
>>>
>>> This is in the HTML section.
>>> And this is in the PHP section.
>>>
>>>
>>> But when I load test.html from my shared web hosting account running
>>> Apache 1.3.3, I get this:
>>>
>>> This is in the HTML section. And this is "; $v2 = "in the PHP section.";
>>> echo $v1 .$v2; ?>
>>>
>>>
>>> My local server does what I expect, but the shared host server just
>>> passes on (some of) the php code. If I change the name of the file from
>>> test.html to test.php, it works.
>>>
>>>
>>> Why does an html extension work on my local server but not on the remote
>>> one? Is it because of the older version of Apache? Or is there a setting
>>> that must be changed?
>>>
>>>
>>>
>>>
>>>
>>>

>>
>>

>
>



  Réponse avec citation
Vieux 12/02/2008, 01h12   #5
Paul Pedersen
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: embed PHP in HTML file


"Lars" <jon.doe@xxxxxxxxxxxxxxxxxx.xxx> wrote in message
news:H14sj.3756$R_4.2795@newsb.telia.net...
>
> Does Apache 1.3.3 support inline PHP scripting in HTML files.


Yes, that was my original question. Or is there a setting that allows that?



> <?php
> phpinfo();
> ?>


I've done that, but being new to web programming, I don't know what most of
that stuff means. I didn't see anything relevant that was obvious to me.


Thanks anyway. I guess I just won't try to embed php code in html files,
because that doesn't seem to work reliably.



  Réponse avec citation
Réponse


Outils de la discussion

Règles de messages
Vous ne pouvez pas créer de nouvelles discussions
Vous ne pouvez pas envoyer des réponses
Vous ne pouvez pas envoyer des pièces jointes
Vous ne pouvez pas modifier vos messages

Les balises BB sont activées : oui
Les smileys sont activés : oui
La balise [IMG] est activée : oui
Le code HTML peut être employé : non
Trackbacks are oui
Pingbacks are oui
Refbacks are oui


Fuseau horaire GMT +1. Il est actuellement 15h37.


Édité par : vBulletin® version 3.7.2
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.2.0 RC5 Tous droits réservés.
Version française #16 par l'association vBulletin francophone
PHWinfo est un site Éducation Sans Frontières
Ad Management by RedTyger
©Tous droits réservés par les parties respectives
Page generated in 0,13645 seconds with 13 queries