PHWinfo banniere

Titres
PORTAIL ANNUAIRE ARTICLES COMPARATEUR HÉBERGEURS DEVIS FORUMS RÉDUCTEUR D'URL
Précédent   PHWinfo > Autres forums > Forum Programmation & Conception > php.general > set
S'inscrire FAQ Membres Recherche Messages du jour Marquer les forums comme lus
set

Réponse
 
LinkBack Outils de la discussion
Vieux 12/03/2008, 13h48   #1
Tim Daff
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut set

Hi,

I am learning PHP, I am trying to set a simple :

<html>
<head>
<title></title>
</head>
<body>

<?php set('test', 45, time()+(60*60*24*7)); ?>

</body>
</html>

Firefox is returning this error:

Warning: Cannot modify header information - headers already sent by
(output started at /Users/Daff/Sites/php_sandbox/.php:7) in /
Users/Daff/Sites/php_sandbox/.php on line 7

I have googled this and can't find out what I am doing wrong. Any
you could give me would be much appreciated.

Tim
  Réponse avec citation
Vieux 12/03/2008, 13h58   #2
Hiep Nguyen
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: [PHP] set

On Wed, 12 Mar 2008, Tim Daff wrote:

> Hi,
>
> I am learning PHP, I am trying to set a simple :
>
> <html>
> <head>
> <title></title>
> </head>
> <body>
> <?php set('test', 45,
> time()+(60*60*24*7)); ?>
> </body>
> </html>
>
> Firefox is returning this error:
>
> Warning: Cannot modify header information - headers already sent by (output
> started at /Users/Daff/Sites/php_sandbox/.php:7) in
> /Users/Daff/Sites/php_sandbox/.php on line 7
>
> I have googled this and can't find out what I am doing wrong. Any you
> could give me would be much appreciated.
>
> Tim


set from php.net states the following:

set() defines a to be sent along with the rest of the HTTP
headers. Like other headers, must be sent before any output from
your script (this is a protocol restriction). This requires that you place
calls to this function prior to any output, including <html> and <head>
tags as well as any whitespace

call set before you output ANY THING, even error

hope that s.
t. hiep
  Réponse avec citation
Vieux 12/03/2008, 14h02   #3
Zareef Ahmed
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: [PHP] set

As a dirty trick you can put following line on the top of your script,
it will work
ob_start();

But you should try to know why it is not working, and what exactly
ob_start will impact your application and What is the thing called
"Output Buffering".

Zareef Ahmed

On 3/12/08, Hiep Nguyen <hiep@ee.ucr.edu> wrote:
>
> On Wed, 12 Mar 2008, Tim Daff wrote:
>
> > Hi,
> >
> > I am learning PHP, I am trying to set a simple :
> >
> > <html>
> > <head>
> > <title></title>
> > </head>
> > <body>
> > <?php set('test', 45,
> > time()+(60*60*24*7)); ?>
> > </body>
> > </html>
> >
> > Firefox is returning this error:
> >
> > Warning: Cannot modify header information - headers already sent by

> (output
> > started at /Users/Daff/Sites/php_sandbox/.php:7) in
> > /Users/Daff/Sites/php_sandbox/.php on line 7
> >
> > I have googled this and can't find out what I am doing wrong. Any

> you
> > could give me would be much appreciated.
> >
> > Tim

>
>
> set from php.net states the following:
>
> set() defines a to be sent along with the rest of the HTTP
> headers. Like other headers, must be sent before any output from
> your script (this is a protocol restriction). This requires that you place
> calls to this function prior to any output, including <html> and <head>
> tags as well as any whitespace
>
> call set before you output ANY THING, even error
>
> hope that s.
> t. hiep
>
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>



--
Zareef Ahmed
http://www.zareef.net
A PHP Developer in India

  Réponse avec citation
Vieux 12/03/2008, 14h15   #4
Richard Heyes
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: [PHP] set

> Firefox is returning this error:
>
> Warning: Cannot modify header information - headers already sent by
> (output started at /Users/Daff/Sites/php_sandbox/.php:7) in
> /Users/Daff/Sites/php_sandbox/.php on line 7


You must use set () before you send any output to the browser,
including whitespace.

--
Richard Heyes
Employ me:
http://www.phpguru.org/cv
  Réponse avec citation
Vieux 12/03/2008, 14h17   #5
Wolf
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: [PHP] set



Tim Daff wrote:
> Hi,
>
> I am learning PHP, I am trying to set a simple :
>
> <html>
> <head>
> <title></title>
> </head>
> <body>
>
> <?php set('test', 45, time()+(60*60*24*7)); ?>
>
> </body>
> </html>
>
> Firefox is returning this error:
>
> Warning: Cannot modify header information - headers already sent by
> (output started at /Users/Daff/Sites/php_sandbox/.php:7) in
> /Users/Daff/Sites/php_sandbox/.php on line 7
>
> I have googled this and can't find out what I am doing wrong. Any
> you could give me would be much appreciated.
>
> Tim


<?php set('test', 45, time()+(60*60*24*7)); ?>
<html>
<head>
<title></title>
</head>
<body>



</body>
</html>

HAVE to be at the top of the page... You output ANYTHING else
and you get the error you wound up getting.

Wolf

  Réponse avec citation
Vieux 12/03/2008, 14h33   #6
Ray Hauge
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: [PHP] set

Wolf wrote:
>
>
> Tim Daff wrote:
>> Hi,
>>
>> I am learning PHP, I am trying to set a simple :
>>
>> <html>
>> <head>
>> <title></title>
>> </head>
>> <body>
>> <?php set('test', 45, time()+(60*60*24*7)); ?>
>> </body>
>> </html>
>>
>> Firefox is returning this error:
>>
>> Warning: Cannot modify header information - headers already sent by
>> (output started at /Users/Daff/Sites/php_sandbox/.php:7) in
>> /Users/Daff/Sites/php_sandbox/.php on line 7
>>
>> I have googled this and can't find out what I am doing wrong. Any
>> you could give me would be much appreciated.
>>
>> Tim

>
> <?php set('test', 45, time()+(60*60*24*7)); ?>
> <html>
> <head>
> <title></title>
> </head>
> <body>
>
>
>
> </body>
> </html>
>
> HAVE to be at the top of the page... You output ANYTHING else
> and you get the error you wound up getting.
>
> Wolf
>
>


If you're not sure if data has already been sent to the client (I ran
into an included file having a space after >?) you can use
http://us3.php.net/manual/en/function.headers-sent.php before you call
set();

If nothing else it'll with diagnosing this error when you run into
it again.

--
Ray Hauge
www.primateapplications.com
  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 23h06.


É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,15707 seconds with 14 queries