• Publicidad

Mostrar mucho código HTML en PHP

Todo lo relacionado con lenguajes de programación distintos de Perl: PHP, Java, C++, Ruby, Python, etc.

Mostrar mucho código HTML en PHP

Notapor BigBear » 2017-01-24 13:32 @605

¿Cuál es la forma correcta de mostrar código HTML en PHP? Teniendo en cuenta que el HTML tiene como 40 líneas y que entre ese código HTML hay algunas variables en PHP, esta pregunta es para un proyecto grande que tengo y quiero que se vea legible.
BigBear
Perlero frecuente
Perlero frecuente
 
Mensajes: 981
Registrado: 2009-03-01 18:39 @818

Publicidad

Re: Mostrar mucho código HTML en PHP

Notapor explorer » 2017-01-24 15:56 @705

Pues igual que lo que haríamos con Perl: con un sistema de plantillas.
JF^D Perl programming & Raku programming. Grupo en Telegram: https://t.me/Perl_ES
Avatar de Usuario
explorer
Administrador
Administrador
 
Mensajes: 14476
Registrado: 2005-07-24 18:12 @800
Ubicación: Valladolid, España

Re: Mostrar mucho código HTML en PHP

Notapor BigBear » 2017-03-05 13:32 @605

Hola, explorer, gracias por responder. Tengo una duda: sin usar plantillas, ¿cuál de estas formas sería mejor para mostrar mucho código HTML?:

Método 1:
Sintáxis: [ Descargar ] [ Ocultar ]
Using php Syntax Highlighting
  1. if (is_single()) {
  2. //now we just close PHP tag
  3. ?>
  4. </style>
  5. <script>
  6. <blah blah blah>
  7. <?php
  8. //open it back. here is your PHP again. easy!
  9. }
  10. ?>
Coloreado en 0.024 segundos, usando GeSHi 1.0.8.4


Método 2:
Sintáxis: [ Descargar ] [ Ocultar ]
Using php Syntax Highlighting
  1. echo <<< EOT
  2.     in here is your string
  3.     it has the same variable substitution rules
  4.     as a double quoted string.
  5.     when you end it, put the indicator word at the
  6.     start of the line (no spaces before it)
  7.     and put a semicolon after it
  8. EOT;
Coloreado en 0.009 segundos, usando GeSHi 1.0.8.4

El primero me queda raro pero es cómodo y el segundo no me convence, pero leí que se usan mucho las dos formas.

¿ Cuál es mejor ?
BigBear
Perlero frecuente
Perlero frecuente
 
Mensajes: 981
Registrado: 2009-03-01 18:39 @818


Volver a Programación en general

¿Quién está conectado?

Usuarios navegando por este Foro: No hay usuarios registrados visitando el Foro y 0 invitados