Foros del Web » Programando para Internet » PHP »

Php incrustado en html

Estas en el tema de Php incrustado en html en el foro de PHP en Foros del Web. Buenas, estoy intentando hacer una página web que lleva trozos de php, antes de realizar la página web he intentado ver si consigo ejecutar correctamente ...
  #1 (permalink)  
Antiguo 04/08/2014, 04:59
 
Fecha de Ingreso: octubre-2012
Mensajes: 37
Antigüedad: 11 años, 6 meses
Puntos: 0
Php incrustado en html

Buenas, estoy intentando hacer una página web que lleva trozos de php, antes de realizar la página web he intentado ver si consigo ejecutar correctamente las instrucciones de php y he realizado el siguiente HTML:

Código HTML:
Ver original
  1. <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
  2.     "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
  3. <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
  4.  
  5.     <title>sin título</title>
  6.     <meta http-equiv="content-type" content="text/html;charset=utf-8" />
  7.     <meta name="generator" content="Geany 1.23.1" />
  8. </head>
  9.  
  10.     <?php
  11.         echo "<img src='./en_construccion.png' border='0' width='300' height='100'>";
  12.     ?>
  13. </body>
  14. </html>

Luego, las he metido en mi carpeta htdocs del xampp version 1.8.2. He leído por ahí que hay que modificar el archivo httpd.conf para que apache ejecute correctamente el php. Me han dicho que busque una línea donde ponga:

AddType application/xhttpdphp .php


Y la cambie por:

AddType application/xhttpdphp .php .phtml .html .js


Pero la línea que había en mi httpd.conf original era:

AddType text/html .shtml


Aún siendo distinta, la he cambiado por:

AddType application/xhttpdphp .php .phtml .html .js



Pero al abrir mi código HTML (anteriormente mostrado) con Chrome y Firefox, sólo veo esto:

"; ?>
  #2 (permalink)  
Antiguo 04/08/2014, 05:22
Avatar de fbedia  
Fecha de Ingreso: julio-2010
Mensajes: 159
Antigüedad: 13 años, 9 meses
Puntos: 8
Respuesta: Php incrustado en html

El codigo esta bien... a mi me corre.
El problema debe estar como comentas en el fichero httpd.conf

Yo lo tengo configurado de la siguiente forma... a ver si te sirve:

Código Apache:
Ver original
  1. AddType application/x-compress .Z
  2.     AddType application/x-gzip .gz .tgz
  3.     AddType application/x-tar .tgz
  4.     AddType image/x-icon .ico
  5.     AddType application/vnd.wap.wmlc .wmlc
  6.     AddType application/x-httpd-php .phtml .pwml .php5 .php4 .php3 .php2 .php .inc
  7.     AddType text/vnd.wap.wml .wml
  8.     AddType text/vnd.wap.wmlscript .wmls
  9.     AddType text/vnd.wap.wmlscriptc .wmlsc
  10.     AddType image/vnd.wap.wbmp .wbmp
__________________
Follow me on twitter @franbedia
  #3 (permalink)  
Antiguo 04/08/2014, 05:35
 
Fecha de Ingreso: octubre-2012
Mensajes: 37
Antigüedad: 11 años, 6 meses
Puntos: 0
Respuesta: Php incrustado en html

Pero eso va entre unas etiquetas de:
<IfModule mime_module>
</IfModule mime_module>

O se añade al final del fichero?
  #4 (permalink)  
Antiguo 04/08/2014, 06:21
Avatar de fbedia  
Fecha de Ingreso: julio-2010
Mensajes: 159
Antigüedad: 13 años, 9 meses
Puntos: 8
Respuesta: Php incrustado en html

Entre las etiquetas que comentas:

Código Apache:
Ver original
  1. <IfModule mime_module>
  2.  
  3.     TypesConfig conf/mime.types
  4.  
  5.  
  6.     AddType application/x-compress .Z
  7.     AddType application/x-gzip .gz .tgz
  8.     AddType application/x-tar .tgz
  9.     AddType image/x-icon .ico
  10.     AddType application/vnd.wap.wmlc .wmlc
  11.     AddType application/x-httpd-php .phtml .pwml .php5 .php4 .php3 .php2 .php .inc
  12.     AddType text/vnd.wap.wml .wml
  13.     AddType text/vnd.wap.wmlscript .wmls
  14.     AddType text/vnd.wap.wmlscriptc .wmlsc
  15.     AddType image/vnd.wap.wbmp .wbmp
  16.  
  17. </IfModule>

Importante:
Ten en cuenta que para que los cambios surgan efecto tienes que reiniciar el proceso de apache.
__________________
Follow me on twitter @franbedia
  #5 (permalink)  
Antiguo 04/08/2014, 06:23
 
Fecha de Ingreso: octubre-2012
Mensajes: 37
Antigüedad: 11 años, 6 meses
Puntos: 0
Respuesta: Php incrustado en html

Vale gracias voy a probarlo que no me he parado a reiniciar el apache

Etiquetas: html
Atención: Estás leyendo un tema que no tiene actividad desde hace más de 6 MESES, te recomendamos abrir un Nuevo tema en lugar de responder al actual.
Respuesta




La zona horaria es GMT -6. Ahora son las 07:03.