Hola. Estoy aprendiendo PHP lo cual me resulta relativamente fácil porque he visto C++ en la facultad, pero en la parte de funciones tengo un problema: A la hora de utilizar la función require() es como si no hiciera nada. Les dejo los códigos a ver si me pueden ayudar a ver en donde le estoy errando. Gracias.
HOME.HTML
<?php require('header.php'); ?>
<!-- Page Content -->
<p>Welcome to the home of TLA Consulting. Please take some time to get to know us.</p>
<p>We specialize in serving your business needs and hope to hear from you soon.</p>
<?php require('footer.php'); ?>
HEADER.PHP
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>TLA Consulting Pty Ltd</title>
<style>
h1{color:white; font-size:24pt; text-align:center; font-family:arial,sans-serif; font-weight:bold}
.menu{color:white; font-size:12pt; text-align:center; font-family:arial,sans-serif}
td{background:black}
p{color:black; font-size:12pt; text-align: justify; font-family: arial,sans-serif; font-weight:bold}
p.foot{color:white; font-size:9pt; text-align:center; font-family:arial,sans-serif; font-weight:bold}
a:link,a:visited,a:active{color:white}
</style>
</head>
<body>
<!-- Page Header -->
<table width="100%" cellpadding="12" cellspacing="0" border="0">
<tr bgcolor="black">
<td align="left"><img src="img/logo.gif" alt="TLA logo" height="70" width="70"></td>
<td><h1>TLA Consulting</h1></td>
<td align="right"><img src="img/logo.gif" alt="TLA logo" height="70" width="70"></td>
</tr>
</table>
<!-- Menu -->
<table width="100%" bgcolor="white" cellpadding="4" cellspacing="4">
<tr>
<td width="25%">
<img src="img/logo.gif" alt="" height="20" width="20">
<span class="menu">Home</span>
</td>
<td width="25%">
<img src="img/logo.gif" alt="" height="20" width="20">
<span class="menu">Contact</span>
</td>
<td width="25%">
<img src="img/logo.gif" alt="" height="20" width="20">
<span class="menu">Services</span>
</td>
<td width="25%">
<img src="img/logo.gif" alt="" height="20" width="20">
<span class="menu">Site Map</span>
</td>
</tr>
</table>
FOOTER.PHP
<!-- Page Footer -->
<table width="100%" bgcolor="black" cellpadding="12" border="0">
<tr>
<td>
<p class="foot">© TLA Consulting Pty Ltd.</p>
<p class="foot">Please see our <a href="legal.php">Legal Information page</a></p>
</td>
</tr>
</table>
</body>
</html>
Mod: Temas sobre PHP van al subforo de PHP.
la pagina no te da errores? te aseguraste que el nombre sea identico? (case sensitive)
Ningún error me tira, solo muestra el contenido que escribo en el archivo home.html, sin mostrar los dos archivos que incluí con require.
Tienen el mismo nombre los archivos.
en el codigo fuente de la pagina cuando se carga, que hay? solo el contenido que pusiste sin las etiquetas php?
¿La página te aparece en blanco?
Revisa la ruta del require, borra el cache de tu navegador.
De igual modo prueba así:
Header.php
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>TLA Consulting Pty Ltd</title>
<style>
h1{color:white; font-size:24pt; text-align:center; font-family:arial,sans-serif; font-weight:bold}
.menu{color:white; font-size:12pt; text-align:center; font-family:arial,sans-serif}
td{background:black}
p{color:black; font-size:12pt; text-align: justify; font-family: arial,sans-serif; font-weight:bold}
p.foot{color:white; font-size:9pt; text-align:center; font-family:arial,sans-serif; font-weight:bold}
a:link,a:visited,a:active{color:white}
</style>
</head>
<body>
<!-- Page Header -->
<table width="100%" cellpadding="12" cellspacing="0" border="0">
<tr bgcolor="black">
<td align="left"><img src="img/logo.gif" alt="TLA logo" height="70" width="70"></td>
<td><h1>TLA Consulting</h1></td>
<td align="right"><img src="img/logo.gif" alt="TLA logo" height="70" width="70"></td>
</tr>
</table>
<!-- Menu -->
<table width="100%" bgcolor="white" cellpadding="4" cellspacing="4">
<tr>
<td width="25%">
<img src="img/logo.gif" alt="" height="20" width="20">
<span class="menu">Home</span>
</td>
<td width="25%">
<img src="img/logo.gif" alt="" height="20" width="20">
<span class="menu">Contact</span>
</td>
<td width="25%">
<img src="img/logo.gif" alt="" height="20" width="20">
<span class="menu">Services</span>
</td>
<td width="25%">
<img src="img/logo.gif" alt="" height="20" width="20">
<span class="menu">Site Map</span>
</td>
</tr>
</table>
<?php require('footer.php'); ?>
</body>
</html>
Footer.php
<table width="100%" bgcolor="black" cellpadding="12" border="0">
<tr>
<td>
<p class="foot">© TLA Consulting Pty Ltd.</p>
<p class="foot">Please see our <a href="legal.php">Legal Information page</a></p>
</td>
</tr>
</table>
Y luego por último el archivo Home.html cámbialo por index.php
y escribes dentro:
<?php require('header.php'); ?>
Prueba así como te dije, copia el código y nos comentas.
Saludos.
Problema solucionado. Solo tenia que guardar el nombre de la web "principal" como .php en vez de .html .
Gracias por la ayuda.