PHWinfo banniere

Titres
PORTAIL ANNUAIRE ARTICLES COMPARATEUR HÉBERGEURS DEVIS FORUMS RÉDUCTEUR D'URL
Précédent   PHWinfo > Autres forums > Forum Programmation & Conception > comp.lang.php > [5.2.5] Alternative to include() to replace a string?
S'inscrire FAQ Membres Recherche Messages du jour Marquer les forums comme lus
[5.2.5] Alternative to include() to replace a string?

Réponse
 
LinkBack Outils de la discussion
Vieux 25/02/2008, 13h48   #1
Gilles Ganault
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut [5.2.5] Alternative to include() to replace a string?

Hello

Currently, I use include(header.inc) to add the HTML header to each
page, but I need to customize the TITLE bit "Some page":

==========
<html> <head> <link rel="STYLESHEET" href="display.css"
type="text/css">
<meta http-equiv="content-type" content="text/html;
charset=iso-8859-1">
<title>Some page</title>
</head>
<body>
==========

Before I replace each include() with
fopen/fread/fclose/str_replace/echo, I was wondering if there were an
easier solution to this?

Thank you.
  Réponse avec citation
Vieux 25/02/2008, 13h57   #2
Paul Herber
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: [5.2.5] Alternative to include() to replace a string?

On Mon, 25 Feb 2008 14:48:09 +0100, Gilles Ganault <nospam@nospam.com>
wrote:

>Hello
>
> Currently, I use include(header.inc) to add the HTML header to each
>page, but I need to customize the TITLE bit "Some page":
>
>==========
><html> <head> <link rel="STYLESHEET" href="display.css"
>type="text/css">
> <meta http-equiv="content-type" content="text/html;
>charset=iso-8859-1">
> <title>Some page</title>
></head>
><body>
>==========
>
>Before I replace each include() with
>fopen/fread/fclose/str_replace/echo, I was wondering if there were an
>easier solution to this?
>
>Thank you.


include_header_inc($title) {
include(header_part1.inc);
echo $title;
include(header_part2.inc);
}

include_header_inc('Your title text')


--
Regards, Paul Herber, Sandrila Ltd.
http://www.sandrila.co.uk/ http://www.pherber.com/
  Réponse avec citation
Vieux 25/02/2008, 13h59   #3
Rik Wasmus
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: [5.2.5] Alternative to include() to replace a string?

On Mon, 25 Feb 2008 14:48:09 +0100, Gilles Ganault <nospam@nospam.com>
wrote:

> Hello
>
> Currently, I use include(header.inc) to add the HTML header to each
> page, but I need to customize the TITLE bit "Some page":
>
> ==========
> <html> <head> <link rel="STYLESHEET" href="display.css"
> type="text/css">
> <meta http-equiv="content-type" content="text/html;
> charset=iso-8859-1">
> <title>Some page</title>
> </head>
> <body>
> ==========
>
> Before I replace each include() with
> fopen/fread/fclose/str_replace/echo, I was wondering if there were an
> easier solution to this?
>
> Thank you.


script.php:
$title = 'foo';
include('header.inc');


header.inc:
<html>
<head>
<link rel="STYLESHEET" href="display.css" type="text/css">
<meta http-equiv="content-type" content="text/html; charset=iso-8859-1">
<title><?php echo isset($title) ? $title : 'Some page'; ?></title>
</head>
<body>
--
Rik Wasmus
  Réponse avec citation
Vieux 25/02/2008, 14h20   #4
ZeldorBlat
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: Alternative to include() to replace a string?

On Feb 25, 8:59 am, "Rik Wasmus" <luiheidsgoe...@hotmail.com> wrote:
> On Mon, 25 Feb 2008 14:48:09 +0100, Gilles Ganault <nos...@nospam.com>
> wrote:
>
>
>
> > Hello

>
> > Currently, I use include(header.inc) to add the HTML header to each
> > page, but I need to customize the TITLE bit "Some page":

>
> > ==========
> > <html> <head> <link rel="STYLESHEET" href="display.css"
> > type="text/css">
> > <meta http-equiv="content-type" content="text/html;
> > charset=iso-8859-1">
> > <title>Some page</title>
> > </head>
> > <body>
> > ==========

>
> > Before I replace each include() with
> > fopen/fread/fclose/str_replace/echo, I was wondering if there were an
> > easier solution to this?

>
> > Thank you.

>
> script.php:
> $title = 'foo';
> include('header.inc');
>
> header.inc:
> <html>
> <head>
> <link rel="STYLESHEET" href="display.css" type="text/css">
> <meta http-equiv="content-type" content="text/html; charset=iso-8859-1">
> <title><?php echo isset($title) ? $title : 'Some page'; ?></title>
> </head>
> <body>
> --
> Rik Wasmus


Or use a function:

function getHeader($title) {
return <<<EOD
<html>
<head>
<link rel="STYLESHEET" href="display.css" type="text/css">
<meta http-equiv="content-type" content="text/html;
charset=iso-8859-1">
<title>$title</title>
</head>
<body>
EOD;
}
  Réponse avec citation
Vieux 25/02/2008, 23h37   #5
Gilles Ganault
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: [5.2.5] Alternative to include() to replace a string?

On Mon, 25 Feb 2008 14:59:19 +0100, "Rik Wasmus"
<luiheidsgoeroe@hotmail.com> wrote:
>script.php:
>$title = 'foo';
>include('header.inc');
>
>
>header.inc:
> <title><?php echo isset($title) ? $title : 'Some page'; ?></title>


Thanks guys for the tip. However, the variable isn't passed to
header.inc. I assume it's due to the way PHP was compiled. Is there
another way to get the content of $title?

//index.php
$title = "List of calls";
include("header.inc");

//header.inc
<title><?php echo isset($title) ? $title : "Change me!"; ?></title>

=> Browser says "Change me!".
  Réponse avec citation
Vieux 25/02/2008, 23h50   #6
Jerry Stuckle
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: [5.2.5] Alternative to include() to replace a string?

Gilles Ganault wrote:
> On Mon, 25 Feb 2008 14:59:19 +0100, "Rik Wasmus"
> <luiheidsgoeroe@hotmail.com> wrote:
>> script.php:
>> $title = 'foo';
>> include('header.inc');
>>
>>
>> header.inc:
>> <title><?php echo isset($title) ? $title : 'Some page'; ?></title>

>
> Thanks guys for the tip. However, the variable isn't passed to
> header.inc. I assume it's due to the way PHP was compiled. Is there
> another way to get the content of $title?
>
> //index.php
> $title = "List of calls";
> include("header.inc");
>
> //header.inc
> <title><?php echo isset($title) ? $title : "Change me!"; ?></title>
>
> => Browser says "Change me!".
>


No, it's not the way PHP is compiled. It does work. What's the actual
code you're using?

--
==================
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
jstucklex@attglobal.net
==================

  Réponse avec citation
Vieux 26/02/2008, 09h23   #7
Robin
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: [5.2.5] Alternative to include() to replace a string?

Gilles Ganault wrote:
> On Mon, 25 Feb 2008 14:59:19 +0100, "Rik Wasmus"
> <luiheidsgoeroe@hotmail.com> wrote:
>> script.php:
>> $title = 'foo';
>> include('header.inc');
>>
>>
>> header.inc:
>> <title><?php echo isset($title) ? $title : 'Some page'; ?></title>

>
> Thanks guys for the tip. However, the variable isn't passed to
> header.inc. I assume it's due to the way PHP was compiled. Is there
> another way to get the content of $title?
>
> //index.php
> $title = "List of calls";
> include("header.inc");
>
> //header.inc
> <title><?php echo isset($title) ? $title : "Change me!"; ?></title>
>
> => Browser says "Change me!".


That should work. Are you sure that you aren't seeing a cached version?
  Réponse avec citation
Vieux 26/02/2008, 14h31   #8
Gilles Ganault
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: [5.2.5] Alternative to include() to replace a string?

On Tue, 26 Feb 2008 09:23:45 +0000, Robin <anon@somewhere.com> wrote:
>That should work. Are you sure that you aren't seeing a cached version?


Sorry guys, it works now. I have no idea why Firefox kept displaying
"Change me" even though I hit F5.
  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 12h58.


Édité par : vBulletin® version 3.7.3
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 ©2000-2008
Ad Management by RedTyger
©Tous droits réservés par les parties respectives
Page generated in 0,22545 seconds with 16 queries